From b2ac4d3bf41bafc1c327b9fa929eee37f05492e8 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sun, 18 Aug 2013 17:25:05 +0200 Subject: [PATCH] unix: retry waitpid() on EINTR Before this commit, libuv would abort() if waitpid() failed with EINTR. It's unlikely that anyone actually hit this error condition: the major UNIX platforms - with the possible exception of Solaris - don't return EINTR when the WNOHANG flag is specified, as libuv does. However, POSIX allows for an implementation to do whatever here: unless explicitly forbidden, it's allowed and POSIX doesn't restrict implementers in this particular area. Let's opt for robustness and handle EINTR. --- src/unix/process.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/unix/process.c b/src/unix/process.c index 267ecb64..7ef84d0d 100644 --- a/src/unix/process.c +++ b/src/unix/process.c @@ -73,7 +73,9 @@ static void uv__chld(uv_signal_t* handle, int signum) { assert(signum == SIGCHLD); for (;;) { - pid = waitpid(-1, &status, WNOHANG); + do + pid = waitpid(-1, &status, WNOHANG); + while (pid == -1 && errno == EINTR); if (pid == 0) return;