From 8a3c0edadbf915b9d2f318412587f6107a8e6d42 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Mon, 9 Mar 2015 15:06:10 -0500 Subject: Fix thinko (don't &toybuf to get scratch space) and add -v option. --- toys/other/timeout.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'toys/other/timeout.c') diff --git a/toys/other/timeout.c b/toys/other/timeout.c index 3824376a..6da2d2e2 100644 --- a/toys/other/timeout.c +++ b/toys/other/timeout.c @@ -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 @@ config TIMEOUT -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 @@ GLOBALS( 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 @@ static void handler(int i) 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 @@ void timeout_main(void) 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; -- cgit v1.2.3