diff options
| author | Eli Zaretskii | 2012-12-21 13:21:35 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2012-12-21 13:21:35 +0200 |
| commit | 7efa3fb3579fcb105ab84748945638daccdb4761 (patch) | |
| tree | 49ee3a0d9ee6d85f75657407367a7413d68f7d93 /src/w32proc.c | |
| parent | c1f02afadfc879f527350dc56d6ed4d2daa7e173 (diff) | |
| download | emacs-7efa3fb3579fcb105ab84748945638daccdb4761.tar.gz emacs-7efa3fb3579fcb105ab84748945638daccdb4761.zip | |
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>.
Diffstat (limited to 'src/w32proc.c')
| -rw-r--r-- | src/w32proc.c | 10 |
1 files changed, 6 insertions, 4 deletions
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) | |||
| 795 | DWORD id; | 795 | DWORD id; |
| 796 | 796 | ||
| 797 | for (cp = child_procs + (child_proc_count-1); cp >= child_procs; cp--) | 797 | for (cp = child_procs + (child_proc_count-1); cp >= child_procs; cp--) |
| 798 | if (!CHILD_ACTIVE (cp)) | 798 | if (!CHILD_ACTIVE (cp) && cp->procinfo.hProcess == NULL) |
| 799 | goto Initialize; | 799 | goto Initialize; |
| 800 | if (child_proc_count == MAX_CHILDREN) | 800 | if (child_proc_count == MAX_CHILDREN) |
| 801 | return NULL; | 801 | return NULL; |
| @@ -852,7 +852,7 @@ delete_child (child_process *cp) | |||
| 852 | if (fd_info[i].cp == cp) | 852 | if (fd_info[i].cp == cp) |
| 853 | emacs_abort (); | 853 | emacs_abort (); |
| 854 | 854 | ||
| 855 | if (!CHILD_ACTIVE (cp)) | 855 | if (!CHILD_ACTIVE (cp) && cp->procinfo.hProcess == NULL) |
| 856 | return; | 856 | return; |
| 857 | 857 | ||
| 858 | /* reap thread if necessary */ | 858 | /* reap thread if necessary */ |
| @@ -896,7 +896,8 @@ delete_child (child_process *cp) | |||
| 896 | if (cp == child_procs + child_proc_count - 1) | 896 | if (cp == child_procs + child_proc_count - 1) |
| 897 | { | 897 | { |
| 898 | for (i = child_proc_count-1; i >= 0; i--) | 898 | for (i = child_proc_count-1; i >= 0; i--) |
| 899 | if (CHILD_ACTIVE (&child_procs[i])) | 899 | if (CHILD_ACTIVE (&child_procs[i]) |
| 900 | || child_procs[i].procinfo.hProcess != NULL) | ||
| 900 | { | 901 | { |
| 901 | child_proc_count = i + 1; | 902 | child_proc_count = i + 1; |
| 902 | break; | 903 | break; |
| @@ -913,7 +914,8 @@ find_child_pid (DWORD pid) | |||
| 913 | child_process *cp; | 914 | child_process *cp; |
| 914 | 915 | ||
| 915 | for (cp = child_procs + (child_proc_count-1); cp >= child_procs; cp--) | 916 | for (cp = child_procs + (child_proc_count-1); cp >= child_procs; cp--) |
| 916 | if (CHILD_ACTIVE (cp) && pid == cp->pid) | 917 | if ((CHILD_ACTIVE (cp) || cp->procinfo.hProcess != NULL) |
| 918 | && pid == cp->pid) | ||
| 917 | return cp; | 919 | return cp; |
| 918 | return NULL; | 920 | return NULL; |
| 919 | } | 921 | } |