commit cea24e923fa4144173e88cc98f57cd822ecb76b4
parent 117210c94aa89e03f0ba8ae9dacf08e77388dcda
Author: phoebos <ben@bvnf.space>
Date: Tue, 11 Oct 2022 14:31:20 +0100
sleep: better error detection
Diffstat:
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/sleep.c b/sleep.c
@@ -1,4 +1,5 @@
#include <errno.h>
+#include <limits.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
@@ -21,7 +22,7 @@ main(int argc, char **argv) {
errno = 0;
unsigned long t = strtoul(argv[1], NULL, 10);
- if (errno || (signed long)t < 0)
+ if (errno || t == ULONG_MAX)
return 1;
while (t > 0)
t = sleep(t);