emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/emacs-24 r111258: More robust creation of a


From: Eli Zaretskii
Subject: [Emacs-diffs] /srv/bzr/emacs/emacs-24 r111258: More robust creation of a subprocess, attempt to solve bug #13546.
Date: Wed, 13 Feb 2013 19:04:30 +0200
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 111258
fixes bug: http://debbugs.gnu.org/13546
committer: Eli Zaretskii <address@hidden>
branch nick: emacs-24
timestamp: Wed 2013-02-13 19:04:30 +0200
message:
  More robust creation of a subprocess, attempt to solve bug #13546.
  
   src/w32proc.c (new_child): If no vacant slots are found in
   child_procs[], make another pass looking for slots whose process
   has exited or died.
modified:
  src/ChangeLog
  src/w32proc.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2013-02-13 17:00:26 +0000
+++ b/src/ChangeLog     2013-02-13 17:04:30 +0000
@@ -1,5 +1,9 @@
 2013-02-13  Eli Zaretskii  <address@hidden>
 
+       * w32proc.c (new_child): If no vacant slots are found in
+       child_procs[], make another pass looking for slots whose process
+       has exited or died.  (Bug#13546)
+
        * w32.c (sys_pipe): When failing due to file descriptors above
        MAXDESC, set errno to EMFILE.
        (_sys_read_ahead): Update cp->status when failing to read serial

=== modified file 'src/w32proc.c'
--- a/src/w32proc.c     2013-02-01 09:23:23 +0000
+++ b/src/w32proc.c     2013-02-13 17:04:30 +0000
@@ -798,6 +798,33 @@
     if (!CHILD_ACTIVE (cp) && cp->procinfo.hProcess == NULL)
       goto Initialize;
   if (child_proc_count == MAX_CHILDREN)
+    {
+      DebPrint (("new_child: No vacant slots, looking for dead processes\n"));
+      for (cp = child_procs + (child_proc_count-1); cp >= child_procs; cp--)
+       if (!CHILD_ACTIVE (cp) && cp->procinfo.hProcess)
+         {
+           DWORD status = 0;
+
+           if (!GetExitCodeProcess (cp->procinfo.hProcess, &status))
+             {
+               DebPrint (("new_child.GetExitCodeProcess: error %lu for PID 
%lu\n",
+                          GetLastError (), cp->procinfo.dwProcessId));
+               status = STILL_ACTIVE;
+             }
+           if (status != STILL_ACTIVE
+               || WaitForSingleObject (cp->procinfo.hProcess, 0) == 
WAIT_OBJECT_0)
+             {
+               DebPrint (("new_child: Freeing slot of dead process %d\n",
+                          cp->procinfo.dwProcessId));
+               CloseHandle (cp->procinfo.hProcess);
+               cp->procinfo.hProcess = NULL;
+               CloseHandle (cp->procinfo.hThread);
+               cp->procinfo.hThread = NULL;
+               goto Initialize;
+             }
+         }
+    }
+  if (child_proc_count == MAX_CHILDREN)
     return NULL;
   cp = &child_procs[child_proc_count++];
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]