aboutsummaryrefslogtreecommitdiff
path: root/toys/posix
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2014-05-31 12:33:24 -0500
committerRob Landley <rob@landley.net>2014-05-31 12:33:24 -0500
commitd8872c43b48eae5501998a4e5a84337017d8fbe6 (patch)
tree8360d8673d0ed40b02f9d58bdf74b639f6e780f9 /toys/posix
parentb0d97a0059555cb0e7e0009b72c038aa67aaa769 (diff)
downloadtoybox-d8872c43b48eae5501998a4e5a84337017d8fbe6.tar.gz
Introduce xfork() and make commands use it, and make some WEXITSTATUS() use WIFEXITED() and WTERMSIG()+127.
Diffstat (limited to 'toys/posix')
-rw-r--r--toys/posix/time.c2
-rw-r--r--toys/posix/xargs.c4
2 files changed, 3 insertions, 3 deletions
diff --git a/toys/posix/time.c b/toys/posix/time.c
index 2648cd1c..01592052 100644
--- a/toys/posix/time.c
+++ b/toys/posix/time.c
@@ -27,7 +27,7 @@ void time_main(void)
struct timeval tv, tv2;
gettimeofday(&tv, NULL);
- if (!(pid = fork())) xexec_optargs(0);
+ if (!(pid = xfork())) xexec_optargs(0);
else {
int stat;
struct rusage ru;
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) {