diff options
| -rw-r--r-- | main.c | 3 | ||||
| -rw-r--r-- | toys/other/chroot.c | 2 | ||||
| -rw-r--r-- | toys/other/netcat.c | 2 | ||||
| -rw-r--r-- | toys/other/nsenter.c | 2 | ||||
| -rw-r--r-- | toys/other/setsid.c | 2 | ||||
| -rw-r--r-- | toys/other/taskset.c | 2 | ||||
| -rw-r--r-- | toys/other/timeout.c | 2 | ||||
| -rw-r--r-- | toys/pending/bootchartd.c | 2 | ||||
| -rw-r--r-- | toys/pending/tcpsvd.c | 2 | ||||
| -rw-r--r-- | toys/posix/nice.c | 2 | ||||
| -rw-r--r-- | toys/posix/nohup.c | 2 | ||||
| -rw-r--r-- | toys/posix/time.c | 2 | 
12 files changed, 14 insertions, 11 deletions
| @@ -127,6 +127,9 @@ void toy_exec(char *argv[])  {    struct toy_list *which; +  // don't blank old optargs if our new argc lives in the old optargs. +  if (argv>=toys.optargs && argv<=toys.optargs+toys.optc) toys.optargs = 0; +    // Return if we can't find it, or need to re-exec to acquire root,    // or if stack depth is getting silly.    if (!(which = toy_find(argv[0]))) return; diff --git a/toys/other/chroot.c b/toys/other/chroot.c index 00fb4e7f..e82dd803 100644 --- a/toys/other/chroot.c +++ b/toys/other/chroot.c @@ -20,6 +20,6 @@ void chroot_main(void)    char *binsh[] = {"/bin/sh", "-i", 0};    if (chdir(*toys.optargs) || chroot(".")) perror_exit("%s", *toys.optargs); -  if (toys.optargs[1]) xexec_optargs(1); +  if (toys.optargs[1]) xexec(toys.optargs+1);    else xexec(binsh);  } diff --git a/toys/other/netcat.c b/toys/other/netcat.c index 616822b7..d27aa885 100644 --- a/toys/other/netcat.c +++ b/toys/other/netcat.c @@ -185,7 +185,7 @@ void netcat_main(void)    set_alarm(0);    if (CFG_NETCAT_LISTEN && (toys.optflags&(FLAG_L|FLAG_l) && toys.optc)) -    xexec_optargs(0); +    xexec(toys.optargs);    // Poll loop copying stdin->socket and socket->stdout.    for (;;) { diff --git a/toys/other/nsenter.c b/toys/other/nsenter.c index d53de41e..8f548bf0 100644 --- a/toys/other/nsenter.c +++ b/toys/other/nsenter.c @@ -112,5 +112,5 @@ void unshare_main(void)      }    } -  xexec_optargs(0); +  xexec(toys.optargs);  } diff --git a/toys/other/setsid.c b/toys/other/setsid.c index 8f0a0647..59a1d78f 100644 --- a/toys/other/setsid.c +++ b/toys/other/setsid.c @@ -24,5 +24,5 @@ void setsid_main(void)      setpgid(0,0);      tcsetpgrp(0, getpid());    } -  xexec_optargs(0); +  xexec(toys.optargs);  } diff --git a/toys/other/taskset.c b/toys/other/taskset.c index bcc03478..2b067d4a 100644 --- a/toys/other/taskset.c +++ b/toys/other/taskset.c @@ -90,7 +90,7 @@ void taskset_main(void)    if (!(toys.optflags & FLAG_p)) {      if (toys.optc < 2) error_exit("Needs 2 args");      do_taskset(getpid(), 1); -    xexec_optargs(1); +    xexec(toys.optargs+1);    } else {      char *c;      pid_t pid = strtol(toys.optargs[toys.optc-1], &c, 10); diff --git a/toys/other/timeout.c b/toys/other/timeout.c index f8acabf5..3824376a 100644 --- a/toys/other/timeout.c +++ b/toys/other/timeout.c @@ -60,7 +60,7 @@ void timeout_main(void)    if (TT.s_signal && -1 == (TT.nextsig = sig_to_num(TT.s_signal)))      error_exit("bad -s: '%s'", TT.s_signal); -  if (!(TT.pid = xfork())) xexec_optargs(1); +  if (!(TT.pid = xfork())) xexec(toys.optargs+1);    else {      int status; diff --git a/toys/pending/bootchartd.c b/toys/pending/bootchartd.c index b29d4f05..d903405f 100644 --- a/toys/pending/bootchartd.c +++ b/toys/pending/bootchartd.c @@ -309,7 +309,7 @@ void bootchartd_main()    if (bchartd_opt == 1 && toys.optargs[1]) {       pid_t prog_pid; -    if (!(prog_pid = xfork())) xexec_optargs(1); +    if (!(prog_pid = xfork())) xexec(toys.optargs+1);      waitpid(prog_pid, NULL, 0);      kill(lgr_pid, SIGUSR1);    } diff --git a/toys/pending/tcpsvd.c b/toys/pending/tcpsvd.c index 585ae733..16110e53 100644 --- a/toys/pending/tcpsvd.c +++ b/toys/pending/tcpsvd.c @@ -392,7 +392,7 @@ void tcpsvd_main(void)        close(1);        dup2(newfd, 0);        dup2(newfd, 1); -      xexec_optargs(2); //skip IP PORT +      xexec(toys.optargs+2); //skip IP PORT      } else {        insert(&pids, pid, addr);        xclose(newfd); //close and reopen for next client. diff --git a/toys/posix/nice.c b/toys/posix/nice.c index bc25d358..4b587ee6 100644 --- a/toys/posix/nice.c +++ b/toys/posix/nice.c @@ -34,5 +34,5 @@ void nice_main(void)    errno = 0;    if (nice(TT.priority)==-1 && errno) perror_exit("Can't set priority"); -  xexec_optargs(0); +  xexec(toys.optargs);  } diff --git a/toys/posix/nohup.c b/toys/posix/nohup.c index df264da2..658ab939 100644 --- a/toys/posix/nohup.c +++ b/toys/posix/nohup.c @@ -38,5 +38,5 @@ void nohup_main(void)      close(0);      open("/dev/null", O_RDONLY);    } -  xexec_optargs(0); +  xexec(toys.optargs);  } diff --git a/toys/posix/time.c b/toys/posix/time.c index 01592052..01da9711 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 = xfork())) xexec_optargs(0); +  if (!(pid = xfork())) xexec(toys.optargs);    else {      int stat;      struct rusage ru; | 
