From 73f5ecd7726daddc291855a5cd6c59f4ec2e0419 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sun, 13 Feb 2022 21:37:39 -0600 Subject: [PATCH] Create the timer after installing the SIGALRM handler. --- toys/other/timeout.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/toys/other/timeout.c b/toys/other/timeout.c index 9f7cd1f1..e93a806c 100644 --- a/toys/other/timeout.c +++ b/toys/other/timeout.c @@ -63,8 +63,6 @@ void timeout_main(void) xparsetimespec(*toys.optargs, &TT.its.it_value); if (TT.k) xparsetimespec(TT.k, &TT.kts); - if (timer_create(CLOCK_MONOTONIC, &se, &TT.timer)) perror_exit("timer"); - TT.nextsig = SIGTERM; if (TT.s && -1 == (TT.nextsig = sig_to_num(TT.s))) error_exit("bad -s: '%s'", TT.s); @@ -77,6 +75,7 @@ void timeout_main(void) int status; xsignal(SIGALRM, handler); + if (timer_create(CLOCK_MONOTONIC, &se, &TT.timer)) perror_exit("timer"); if (timer_settime(TT.timer, 0, &TT.its, 0)) perror_exit("timer_settime"); status = xwaitpid(TT.pid); -- 2.39.2