Date: Wed, 22 Aug 2018 09:49:38 +0000 (UTC) From: Eitan Adler <eadler@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r338187 - head/usr.bin/top Message-ID: <201808220949.w7M9ncmU058443@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: eadler Date: Wed Aug 22 09:49:38 2018 New Revision: 338187 URL: https://svnweb.freebsd.org/changeset/base/338187 Log: top(1): issue warning on invalid delay When top -sH is run it continually updates. It should issue an warning instead. Reported by: jmg PR: 230803 Modified: head/usr.bin/top/top.c Modified: head/usr.bin/top/top.c ============================================================================== --- head/usr.bin/top/top.c Wed Aug 22 09:27:40 2018 (r338186) +++ head/usr.bin/top/top.c Wed Aug 22 09:49:38 2018 (r338187) @@ -21,6 +21,7 @@ #include <sys/signal.h> #include <assert.h> +#include <err.h> #include <errno.h> #include <getopt.h> #include <jail.h> @@ -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",
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201808220949.w7M9ncmU058443>