aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2015-03-09 15:06:10 -0500
committerRob Landley <rob@landley.net>2015-03-09 15:06:10 -0500
commit8a3c0edadbf915b9d2f318412587f6107a8e6d42 (patch)
tree61ae3dcc2a052108fa58d759e430170cfc77dd6a
parente6abb61e057d55a08c263a48648aaf7b776dfcee (diff)
downloadtoybox-8a3c0edadbf915b9d2f318412587f6107a8e6d42.tar.gz
Fix thinko (don't &toybuf to get scratch space) and add -v option.
-rw-r--r--toys/other/timeout.c8
1 files changed, 5 insertions, 3 deletions
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;