Subject: Re: bug#13079: 24.3.50; Emacs cannot create subprocess
From: Eli Zaretskii <[email-masked]>
To: [email-masked]
Cc: [email-masked]
Date: Sat, 15 Dec 2012 15:41:41 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

> Date: Wed, 05 Dec 2012 19:29:58 +0200
> From: Eli Zaretskii <[email-masked]>
> Cc: [email-masked]
> 
> The harder part of this bug is the reason _why_ 'mktemp' fails.  Your
> command launches asynchronous subprocesses, creating a temporary file
> for each one of them where Emacs puts the contents of the region.  In
> this case, call-process-region arranges for the temporary files to be
> removed when the call to call-process returns, and then calls
> call-process.  However, since this is an async subprocess,
> call-process returns immediately, without waiting for the subprocess
> to exit, and Emacs deletes the temporary file.  This "cleanup" uses
> the non-portable (outside of Posix filesystems) trick of deleting a
> file while it is still open and used by the child process.  On
> Windows, this attempt to delete the file fails, and the file is left
> behind.
> 
> The other part of this puzzle is that 'mktemp' as implemented by the
> Windows runtime can only have up to 42 simultaneous temporary files
> per calling thread (the MSDN documentation says 26, but that's a lie).
> Once there are 42 files in your TEMP directory created by a single
> Emacs session, all the future calls to 'mktemp' from the same session
> will fail, unless you manually delete those files.
> 
> This part of the bug is harder to solve, because some code needs to be
> implemented that will defer deletion until the process exits.  So it
> is not solved yet.

Should be fixed now (revision 11244 on the trunk).  I was able to run
your test case multiple times without any errors, and after that,
there were no left-over temporary files in the temporary directory.