# HG changeset patch # User Rob Landley # Date 1425931570 18000 # Node ID 26170eb7685d4016c68104aefd5d12aafbfa483f # Parent b2b2d214727ad809e8556ff1beda1fbb329b9d2e Fix thinko (don't &toybuf to get scratch space) and add -v option. diff -r b2b2d214727a -r 26170eb7685d toys/other/timeout.c --- a/toys/other/timeout.c Mon Mar 09 14:52:32 2015 -0500 +++ b/toys/other/timeout.c Mon Mar 09 15:06:10 2015 -0500 @@ -4,7 +4,7 @@ * * No standard -USE_TIMEOUT(NEWTOY(timeout, "<2^k:s: ", TOYFLAG_BIN)) +USE_TIMEOUT(NEWTOY(timeout, "<2^vk:s: ", TOYFLAG_BIN)) config TIMEOUT bool "timeout" @@ -21,6 +21,7 @@ -s Send specified signal (default TERM) -k Send KILL signal if child still running this long after first signal. + -v Verbose */ #define FOR_timeout @@ -38,6 +39,7 @@ static void handler(int i) { + fprintf(stderr, "timeout pid %d signal %d\n", TT.pid, TT.nextsig); kill(TT.pid, TT.nextsig); if (TT.k_timeout) { @@ -45,7 +47,7 @@ TT.nextsig = SIGKILL; signal(SIGALRM, handler); TT.itv.it_value = TT.ktv; - setitimer(ITIMER_REAL, &TT.itv, (void *)&toybuf); + setitimer(ITIMER_REAL, &TT.itv, (void *)toybuf); } } @@ -65,7 +67,7 @@ int status; signal(SIGALRM, handler); - setitimer(ITIMER_REAL, &TT.itv, (void *)&toybuf); + setitimer(ITIMER_REAL, &TT.itv, (void *)toybuf); while (-1 == waitpid(TT.pid, &status, 0) && errno == EINTR); toys.exitval = WIFEXITED(status) ? WEXITSTATUS(status) : WTERMSIG(status) + 127;