diff --git a/usr.bin/top/top.c b/usr.bin/top/top.c index 558491da3c3b..b76dbb54676d 100644 --- a/usr.bin/top/top.c +++ b/usr.bin/top/top.c @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -253,6 +254,7 @@ main(int argc, char *argv[]) char *order_name = NULL; int order_index = 0; fd_set readfds; + char *nptr; /* set the buffer for stdout */ #ifdef DEBUG @@ -386,7 +388,12 @@ main(int argc, char *argv[]) } case 's': - delay = strtod(optarg, NULL); + delay = strtod(optarg, &nptr); + if (nptr == optarg) { + warnx("warning: invalid delay"); + delay = 2; + warnings++; + } if (delay < 0) { fprintf(stderr, "%s: warning: seconds delay should be positive -- using default\n",