Commit e86f5134 authored by Eli Zaretskii's avatar Eli Zaretskii
Browse files

Avoid busy-waiting for child processes on Windows. (Bug#13086)

 src/w32proc.c (waitpid): Avoid busy-waiting when called with WNOHANG
 if the child process is still running.  Instead, exit the wait
 loop and return zero.
parent 5b4d7e52
2012-12-06 Eli Zaretskii <eliz@gnu.org>
* w32proc.c (waitpid): Avoid busy-waiting when called with WNOHANG
if the child process is still running. Instead, exit the wait
loop and return zero. (Bug#13086)
2012-12-06 Dmitry Antipov <dmantipov@yandex.ru> 2012-12-06 Dmitry Antipov <dmantipov@yandex.ru>
   
* frame.h (x_char_width, x_char_height): Remove prototypes. * frame.h (x_char_width, x_char_height): Remove prototypes.
......
...@@ -1220,13 +1220,22 @@ waitpid (pid_t pid, int *status, int options) ...@@ -1220,13 +1220,22 @@ waitpid (pid_t pid, int *status, int options)
{ {
QUIT; QUIT;
active = WaitForMultipleObjects (nh, wait_hnd, FALSE, timeout_ms); active = WaitForMultipleObjects (nh, wait_hnd, FALSE, timeout_ms);
} while (active == WAIT_TIMEOUT); } while (active == WAIT_TIMEOUT && !dont_wait);
if (active == WAIT_FAILED) if (active == WAIT_FAILED)
{ {
errno = EBADF; errno = EBADF;
return -1; return -1;
} }
else if (active == WAIT_TIMEOUT && dont_wait)
{
/* PID specifies our subprocess, but it didn't exit yet, so its
status is not yet available. */
#ifdef FULL_DEBUG
DebPrint (("Wait: PID %d not reap yet\n", cp->pid));
#endif
return 0;
}
else if (active >= WAIT_OBJECT_0 else if (active >= WAIT_OBJECT_0
&& active < WAIT_OBJECT_0+MAXIMUM_WAIT_OBJECTS) && active < WAIT_OBJECT_0+MAXIMUM_WAIT_OBJECTS)
{ {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment