authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-09-08 00:45:45-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-09-08 00:45:45-04:00
log838d52a8beaf1eaa9ca7efe1d586d1ad4925560e
tree5d3e4edc713b22e5c16feca901edd86b52d26612
parenta81e5161746b89e490bbf167489fd43a9d1821c2

std.os.ChildProcess: don't expect all SIGCHLD to come from spawn


1 files changed, 5 insertions(+), 4 deletions(-)

std/os/child_process.zig+5-4
...@@ -341,8 +341,11 @@ extern fn sigchld_handler(_: i32) {...@@ -341,8 +341,11 @@ extern fn sigchld_handler(_: i32) {
341 var status: i32 = undefined;341 var status: i32 = undefined;
342 const pid_result = posix.waitpid(-1, &status, posix.WNOHANG);342 const pid_result = posix.waitpid(-1, &status, posix.WNOHANG);
343 const err = posix.getErrno(pid_result);343 const err = posix.getErrno(pid_result);
344 if (err == posix.ECHILD) {344 if (err > 0) {
345 return;345 if (err == posix.ECHILD) {
346 return;
347 }
348 unreachable;
346 }349 }
347 handleTerm(i32(pid_result), status);350 handleTerm(i32(pid_result), status);
348 }351 }
...@@ -352,12 +355,10 @@ fn handleTerm(pid: i32, status: i32) {...@@ -352,12 +355,10 @@ fn handleTerm(pid: i32, status: i32) {
352 var it = children_nodes.first;355 var it = children_nodes.first;
353 while (it) |node| : (it = node.next) {356 while (it) |node| : (it = node.next) {
354 if (node.data.pid == pid) {357 if (node.data.pid == pid) {
355 assert(node.data.term == null);
356 node.data.handleWaitResult(status);358 node.data.handleWaitResult(status);
357 return;359 return;
358 }360 }
359 }361 }
360 unreachable;
361}362}
362363
363const sigchld_set = {364const sigchld_set = {