aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;