bore

basic core utilities (PD)
git clone git://bvnf.space/bore.git
Log | Files | Refs | README

commit 8416a7600224c522f3527ca50fbf1d25e220853b
parent 954790d3acb7cd91aa1fe22ec19eb1c45caa3037
Author: phoebos <ben@bvnf.space>
Date:   Sat,  1 Oct 2022 22:28:27 +0100

sleep: exit normally on SIGALRM

Diffstat:
Msleep.c | 9+++++++++
1 file changed, 9 insertions(+), 0 deletions(-)

diff --git a/sleep.c b/sleep.c @@ -1,8 +1,15 @@ #include <errno.h> +#include <signal.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> +void +sig_handler(int sig) { + (void)sig; + exit(0); +} + int main(int argc, char **argv) { if (argc != 2) { @@ -10,6 +17,8 @@ main(int argc, char **argv) { return 1; } + signal(SIGALRM, sig_handler); + errno = 0; unsigned long t = strtoul(argv[1], NULL, 10); if (errno || (signed long)t < 0)