summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-09-25 11:42:10 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-09-25 11:42:10 +0000
commitc8842213f5ad95b1b6e32d2db1dce5ce8c04ece9 (patch)
tree6c325a8e053f1ec30ae4e6a2684fffea851a38b2
parent42cc6bab16a6b451ab1b36e302100afcd95e6634 (diff)
top: fix "top -d 1" (bug 5144)
-rw-r--r--procps/top.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/procps/top.c b/procps/top.c
index b481d395e..908ae8151 100644
--- a/procps/top.c
+++ b/procps/top.c
@@ -894,7 +894,7 @@ int top_main(int argc UNUSED_PARAM, char **argv)
unsigned lines, col;
int lines_rem;
unsigned interval;
- char *sinterval;
+ char *str_interval, *str_iterations;
SKIP_FEATURE_TOPMEM(const) unsigned scan_mask = TOP_MASK;
#if ENABLE_FEATURE_USE_TERMIOS
struct termios new_settings;
@@ -917,10 +917,19 @@ int top_main(int argc UNUSED_PARAM, char **argv)
#endif
/* all args are options; -n NUM */
- opt_complementary = "-:n+";
- if (getopt32(argv, "d:n:b", &sinterval, &iterations) & OPT_d) {
+ opt_complementary = "-";
+ col = getopt32(argv, "d:n:b", &str_interval, &str_iterations);
+ if (col & OPT_d) {
+ /* work around for "-d 1" -> "-d -1" done by getopt32 */
+ if (str_interval[0] == '-')
+ str_interval++;
/* Need to limit it to not overflow poll timeout */
- interval = xatou16(sinterval); /* -d */
+ interval = xatou16(str_interval);
+ }
+ if (col & OPT_n) {
+ if (str_iterations[0] == '-')
+ str_iterations++;
+ iterations = xatou(str_iterations);
}
/* change to /proc */