summaryrefslogtreecommitdiff
path: root/src/w32proc.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2013-02-14 22:35:54 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2013-02-14 22:35:54 -0800
commit648e5523fbfc3dfbce58f66437112bc442470c87 (patch)
tree6ead7871ba1026168c7f7c4d1f4cffa5241f864b /src/w32proc.c
parentdec2a322921d74de8f251a54931d4c50ab00713d (diff)
parent974c7646ec5b2985a50007c9d599154d667df349 (diff)
downloademacs-648e5523fbfc3dfbce58f66437112bc442470c87.tar.gz
Merge from emacs-24; up to 2012-12-19T13:01:16Z!michael.albinus@gmx.de
Diffstat (limited to 'src/w32proc.c')
-rw-r--r--src/w32proc.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/w32proc.c b/src/w32proc.c
index 8bf57602927..ce1474c7323 100644
--- a/src/w32proc.c
+++ b/src/w32proc.c
@@ -803,6 +803,33 @@ new_child (void)
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++];