diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2019-09-27 20:53:31 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2019-09-27 20:53:31 +0000 |
commit | fc4ac32fa7b7c4af4a360612cad271afd6dc8cb8 (patch) | |
tree | 8ad3ef59da435db9ecb6028ced002e8fa363b114 /usr.bin/top | |
parent | a6f721ece8259d41096eae6527ff0b2c101144a1 (diff) | |
download | src-test2-fc4ac32fa7b7c4af4a360612cad271afd6dc8cb8.tar.gz src-test2-fc4ac32fa7b7c4af4a360612cad271afd6dc8cb8.zip |
Allow entering fractional delays in top(1) interactive mode.
This uses the same logic as with the -s option, first validating the
entered value, then storing the result in a struct timeval.
MFC after: 3 days
X-MFC-With: r352818
Notes
Notes:
svn path=/head/; revision=352819
Diffstat (limited to 'usr.bin/top')
-rw-r--r-- | usr.bin/top/top.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/usr.bin/top/top.c b/usr.bin/top/top.c index cd357a092e9f..3b317fab88b7 100644 --- a/usr.bin/top/top.c +++ b/usr.bin/top/top.c @@ -886,12 +886,22 @@ restart: case CMD_delay: /* new seconds delay */ new_message(MT_standout, "Seconds to delay: "); - if ((i = readline(tempbuf1, 8, true)) > 0) + if ((i = readline(tempbuf1, 8, false)) > 0) { - delay.tv_sec = i; - delay.tv_usec = 0; + double delay_d = strtod(tempbuf1, &nptr); + if (nptr == tempbuf1 || delay_d <= 0) + { + new_message(MT_standout, " Invalid delay"); + putchar('\r'); + no_command = true; + } + else + { + delay.tv_sec = delay_d; + delay.tv_usec = (delay_d - delay.tv_sec) * 1e6; + clear_message(); + } } - clear_message(); break; case CMD_displays: /* change display count */ |