diff options
-rw-r--r-- | src/randsleep.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/randsleep.c b/src/randsleep.c index bf7bdc3..23db7a7 100644 --- a/src/randsleep.c +++ b/src/randsleep.c @@ -5,13 +5,19 @@ int main (int argc, char **argv) { long maxsleep; + char * strtol_err; if (argc < 2) { fputs("Usage: randsleep <max> [<cmd> [<args ...>]]\n", stderr); return 1; } - maxsleep = atol(argv[1]); + maxsleep = strtol(argv[1], &strtol_err, 0); + + if (strtol_err) { + printf("randsleep: strtol: Conversion error at '%s'\n", strtol_err); + return 1; + } srand(time(NULL) + getpid()); |