Mercurial > hg > toybox
changeset 1726:26170eb7685d draft
Fix thinko (don't &toybuf to get scratch space) and add -v option.
author | Rob Landley <rob@landley.net> |
---|---|
date | Mon, 09 Mar 2015 15:06:10 -0500 |
parents | b2b2d214727a |
children | c0ef9b7976f0 |
files | toys/other/timeout.c |
diffstat | 1 files changed, 5 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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;