diff options
author | Marius Halden <marius.h@lden.org> | 2016-11-04 14:42:48 +0100 |
---|---|---|
committer | Marius Halden <marius.h@lden.org> | 2016-11-04 14:42:48 +0100 |
commit | 48e4273e1a0fd7f0480f92350932ec457dbcfe13 (patch) | |
tree | b32e0c3f002db7d22b58e9ec390da116ebc566fd /runfd.c | |
parent | c94026c430a89cc2e62580fb7f7f6dd4b101a12c (diff) | |
download | runq-48e4273e1a0fd7f0480f92350932ec457dbcfe13.tar.gz runq-48e4273e1a0fd7f0480f92350932ec457dbcfe13.tar.bz2 runq-48e4273e1a0fd7f0480f92350932ec457dbcfe13.tar.xz |
atoi() -> strtol() in runfd.c
Diffstat (limited to 'runfd.c')
-rw-r--r-- | runfd.c | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -10,18 +10,22 @@ * NOTE: requires fdescfs to be mounted to run interpreted files (starting with #!) */ +#define DEFAULT_FD 3 + char *args[] = { "batchrun", NULL }; int main(int argc, char **argv) { - char buf[2]; + char buf[2], *end = NULL; ssize_t ret; - int tries = 0; - int fd = 3; + int tries = 0, fd = DEFAULT_FD; if (argc > 1) { - fd = atoi(argv[1]); + fd = strtol(argv[1], &end, 10); + + if (end == argv[1]) + errx(1, "Filedescriptor supplied (\"%s\") is not a number", argv[1]); } retry: @@ -36,6 +40,7 @@ retry: } else if (ret == -1) { if (errno == EINTR) goto retry; + err(1, "pread()"); } else if (ret != 0) { goto retry; } |