summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2012-12-21 13:21:35 +0200
committerEli Zaretskii <eliz@gnu.org>2012-12-21 13:21:35 +0200
commitd2b9c238d5eb58b754a42c03d29e47a5de86f1de (patch)
tree3973be395a51cff02b2c855da36aa94a93979144
parent3f76e2585983349f7cd0a62ca6cd7b3ed9553e57 (diff)
downloademacs-d2b9c238d5eb58b754a42c03d29e47a5de86f1de.tar.gz
Possibly fix bug #13086 with losing track of subprocesses on MS-Windows.
src/w32proc.c (new_child, delete_child, find_child_pid): For a subprocess, consider its slot being in use as long as its process handle (procinfo.hProcess) is not NULL. This avoids reusing the slot when a new process is started immediately after killing another one, without waiting enough time for the first process to be reaped and resources allocated for it be orderly freed. Suggested by Fabrice Popineau <fabrice.popineau@supelec.fr>.
-rw-r--r--src/ChangeLog11
-rw-r--r--src/w32proc.c10
2 files changed, 17 insertions, 4 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index b98d7835157..2ffe7e8f4af 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,14 @@
+2012-12-21 Eli Zaretskii <eliz@gnu.org>
+
+ * w32proc.c (new_child, delete_child, find_child_pid): For a
+ subprocess, consider its slot being in use as long as its process
+ handle (procinfo.hProcess) is not NULL. This avoids reusing the
+ slot when a new process is started immediately after killing
+ another one, without waiting enough time for the first process to
+ be reaped and resources allocated for it be orderly freed.
+ (Bug#13086)
+ Suggested by Fabrice Popineau <fabrice.popineau@supelec.fr>.
+
2012-12-21 Chong Yidong <cyd@gnu.org>
* buffer.c (Fset_buffer_major_mode): Doc fix (Bug#13231).
diff --git a/src/w32proc.c b/src/w32proc.c
index e3c54fe5460..03360075a09 100644
--- a/src/w32proc.c
+++ b/src/w32proc.c
@@ -795,7 +795,7 @@ new_child (void)
DWORD id;
for (cp = child_procs + (child_proc_count-1); cp >= child_procs; cp--)
- if (!CHILD_ACTIVE (cp))
+ if (!CHILD_ACTIVE (cp) && cp->procinfo.hProcess == NULL)
goto Initialize;
if (child_proc_count == MAX_CHILDREN)
return NULL;
@@ -852,7 +852,7 @@ delete_child (child_process *cp)
if (fd_info[i].cp == cp)
emacs_abort ();
- if (!CHILD_ACTIVE (cp))
+ if (!CHILD_ACTIVE (cp) && cp->procinfo.hProcess == NULL)
return;
/* reap thread if necessary */
@@ -896,7 +896,8 @@ delete_child (child_process *cp)
if (cp == child_procs + child_proc_count - 1)
{
for (i = child_proc_count-1; i >= 0; i--)
- if (CHILD_ACTIVE (&child_procs[i]))
+ if (CHILD_ACTIVE (&child_procs[i])
+ || child_procs[i].procinfo.hProcess != NULL)
{
child_proc_count = i + 1;
break;
@@ -913,7 +914,8 @@ find_child_pid (DWORD pid)
child_process *cp;
for (cp = child_procs + (child_proc_count-1); cp >= child_procs; cp--)
- if (CHILD_ACTIVE (cp) && pid == cp->pid)
+ if ((CHILD_ACTIVE (cp) || cp->procinfo.hProcess != NULL)
+ && pid == cp->pid)
return cp;
return NULL;
}