From d8872c43b48eae5501998a4e5a84337017d8fbe6 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 31 May 2014 12:33:24 -0500 Subject: Introduce xfork() and make commands use it, and make some WEXITSTATUS() use WIFEXITED() and WTERMSIG()+127. --- toys/posix/xargs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'toys/posix/xargs.c') diff --git a/toys/posix/xargs.c b/toys/posix/xargs.c index b024789f..cde71f61 100644 --- a/toys/posix/xargs.c +++ b/toys/posix/xargs.c @@ -166,14 +166,14 @@ void xargs_main(void) for (dtemp = dlist; dtemp; dtemp = dtemp->next) handle_entries(dtemp->data, out+entries); - pid_t pid=fork(); + pid_t pid=xfork(); if (!pid) { xclose(0); open("/dev/null", O_RDONLY); xexec(out); } waitpid(pid, &status, 0); - status = WEXITSTATUS(status); + status = WIFEXITED(status) ? WEXITSTATUS(status) : WTERMSIG(status)+127; // Abritrary number of execs, can't just leak memory each time... while (dlist) { -- cgit v1.2.3