moonbridge
diff moonbridge_io.c @ 298:09d6428fdf6c
Fixed wrong treatment of waitpid() return value in moonbridge_io.poll(...)
author | jbe |
---|---|
date | Sun Jun 18 01:01:45 2017 +0200 (2017-06-18) |
parents | dd0ec48592e7 |
children | f9e8fbec2063 |
line diff
1.1 --- a/moonbridge_io.c Sat Jun 17 22:43:44 2017 +0200 1.2 +++ b/moonbridge_io.c Sun Jun 18 01:01:45 2017 +0200 1.3 @@ -1671,7 +1671,7 @@ 1.4 int use_timeout = 0; // negative for negative timeout 1.5 int check_sigterm = 0; 1.6 int check_sigchld = 0; 1.7 - int childstatus; 1.8 + pid_t waitedpid; 1.9 sigset_t mask, orig_mask; 1.10 int status; 1.11 FD_ZERO(&readfds); 1.12 @@ -1708,11 +1708,14 @@ 1.13 moonbr_io_sigchld_flag = 0; 1.14 signal(SIGCHLD, moonbr_io_sigchld_handler); 1.15 } 1.16 - if (waitpid(child->pid, &childstatus, WNOHANG|WNOWAIT) != -1) { 1.17 + while ((waitedpid = waitpid(child->pid, &status, WNOHANG|WNOWAIT)) == -1) { 1.18 + if (errno != EINTR) { 1.19 + moonbr_io_prepare_errmsg(); 1.20 + luaL_error(L, "Error in waitpid call: %s", errmsg); 1.21 + } 1.22 + } 1.23 + if (waitedpid) { 1.24 force_wakeup = 1; 1.25 - } else if (errno != ECHILD && errno != EINTR) { 1.26 - moonbr_io_prepare_errmsg(); 1.27 - luaL_error(L, "Error in waitpid call: %s", errmsg); 1.28 } 1.29 continue; 1.30 } else {