diff options
| author | Eli Zaretskii | 2013-02-13 19:04:30 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2013-02-13 19:04:30 +0200 |
| commit | 0e4e7b741b515be091e2ec3b3ff63f1b16084555 (patch) | |
| tree | e9c3944bb91f44bf0375e62cc7e8d93e97c2300e /src/w32proc.c | |
| parent | 6e432f0cda1daa7bcee1fb5872dcfa130abe5018 (diff) | |
| download | emacs-0e4e7b741b515be091e2ec3b3ff63f1b16084555.tar.gz emacs-0e4e7b741b515be091e2ec3b3ff63f1b16084555.zip | |
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.
Diffstat (limited to 'src/w32proc.c')
| -rw-r--r-- | src/w32proc.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/w32proc.c b/src/w32proc.c index 8c09a1b1beb..1e72d41e16b 100644 --- a/src/w32proc.c +++ b/src/w32proc.c | |||
| @@ -798,6 +798,33 @@ new_child (void) | |||
| 798 | if (!CHILD_ACTIVE (cp) && cp->procinfo.hProcess == NULL) | 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 | { | ||
| 802 | DebPrint (("new_child: No vacant slots, looking for dead processes\n")); | ||
| 803 | for (cp = child_procs + (child_proc_count-1); cp >= child_procs; cp--) | ||
| 804 | if (!CHILD_ACTIVE (cp) && cp->procinfo.hProcess) | ||
| 805 | { | ||
| 806 | DWORD status = 0; | ||
| 807 | |||
| 808 | if (!GetExitCodeProcess (cp->procinfo.hProcess, &status)) | ||
| 809 | { | ||
| 810 | DebPrint (("new_child.GetExitCodeProcess: error %lu for PID %lu\n", | ||
| 811 | GetLastError (), cp->procinfo.dwProcessId)); | ||
| 812 | status = STILL_ACTIVE; | ||
| 813 | } | ||
| 814 | if (status != STILL_ACTIVE | ||
| 815 | || WaitForSingleObject (cp->procinfo.hProcess, 0) == WAIT_OBJECT_0) | ||
| 816 | { | ||
| 817 | DebPrint (("new_child: Freeing slot of dead process %d\n", | ||
| 818 | cp->procinfo.dwProcessId)); | ||
| 819 | CloseHandle (cp->procinfo.hProcess); | ||
| 820 | cp->procinfo.hProcess = NULL; | ||
| 821 | CloseHandle (cp->procinfo.hThread); | ||
| 822 | cp->procinfo.hThread = NULL; | ||
| 823 | goto Initialize; | ||
| 824 | } | ||
| 825 | } | ||
| 826 | } | ||
| 827 | if (child_proc_count == MAX_CHILDREN) | ||
| 801 | return NULL; | 828 | return NULL; |
| 802 | cp = &child_procs[child_proc_count++]; | 829 | cp = &child_procs[child_proc_count++]; |
| 803 | 830 | ||