aboutsummaryrefslogtreecommitdiff
path: root/toys/posix
diff options
context:
space:
mode:
Diffstat (limited to 'toys/posix')
-rw-r--r--toys/posix/cpio.c11
-rw-r--r--toys/posix/time.c2
-rw-r--r--toys/posix/xargs.c4
3 files changed, 10 insertions, 7 deletions
diff --git a/toys/posix/cpio.c b/toys/posix/cpio.c
index 312bb939..a442f0d1 100644
--- a/toys/posix/cpio.c
+++ b/toys/posix/cpio.c
@@ -82,12 +82,15 @@ void cpio_main(void)
// In passthrough mode, parent stays in original dir and generates archive
// to pipe, child does chdir to new dir and reads archive from stdin (pipe).
if (TT.pass) {
- if (!(pid = xpopen(0, &pipe, 0))) {
+ if (toys.stacktop) {
+ // xpopen() doesn't return from child due to vfork(), instead restarts
+ // with !toys.stacktop
+ pid = xpopen(0, &pipe, 0);
+ afd = pipe;
+ } else {
+ // child
toys.optflags |= FLAG_i;
xchdir(TT.pass);
- } else {
- toys.optflags |= FLAG_o;
- afd = pipe;
}
}
diff --git a/toys/posix/time.c b/toys/posix/time.c
index b3cfd26b..2151826d 100644
--- a/toys/posix/time.c
+++ b/toys/posix/time.c
@@ -28,7 +28,7 @@ void time_main(void)
struct timeval tv, tv2;
gettimeofday(&tv, NULL);
- if (!(pid = xvfork())) xexec(toys.optargs);
+ if (!(pid = XVFORK())) xexec(toys.optargs);
else {
int stat;
struct rusage ru;
diff --git a/toys/posix/xargs.c b/toys/posix/xargs.c
index 50c42620..b4cb80a0 100644
--- a/toys/posix/xargs.c
+++ b/toys/posix/xargs.c
@@ -111,6 +111,7 @@ void xargs_main(void)
struct double_list *dlist = NULL, *dtemp;
int entries, bytes, done = 0, status;
char *data = NULL, **out;
+ pid_t pid;
if (!(toys.optflags & FLAG_0)) TT.delim = '\n';
@@ -168,8 +169,7 @@ void xargs_main(void)
for (dtemp = dlist; dtemp; dtemp = dtemp->next)
handle_entries(dtemp->data, out+entries);
- pid_t pid=xvfork();
- if (!pid) {
+ if (!(pid = XVFORK())) {
xclose(0);
open("/dev/null", O_RDONLY);
xexec(out);