summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--runfd.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/runfd.c b/runfd.c
index 3a3260e..50eea7f 100644
--- a/runfd.c
+++ b/runfd.c
@@ -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;
}