#include <sys/time.h>
#include <time.h>
#include <stdlib.h>
+#include <errno.h>
#include <sys/select.h>
#include <sys/types.h>
#include <sys/wait.h>
int cidx = 0;
int returncode = 0;
int replace_cb = 0;
+ char *t;
while ((opt = getopt(argc, argv, "+hij:l:")) != -1) {
switch (opt) {
replace_cb = 1;
break;
case 'j':
- maxjobs = atoi(optarg);
+ errno = 0;
+ maxjobs = strtoul(optarg, &t, 0);
+ if (errno != 0 || (t-optarg) != strlen(optarg)) {
+ fprintf(stderr, "option '%s' is not a number\n",
+ optarg);
+ exit(2);
+ }
break;
case 'l':
- maxload = atoi(optarg);
+ errno = 0;
+ maxload = strtoul(optarg, &t, 0);
+ if (errno != 0 || (t-optarg) != strlen(optarg)) {
+ fprintf(stderr, "option '%s' is not a number\n",
+ optarg);
+ exit(2);
+ }
break;
default: /* ’?’ */
usage();