diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-09-25 11:42:10 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-09-25 11:42:10 +0000 |
commit | c8842213f5ad95b1b6e32d2db1dce5ce8c04ece9 (patch) | |
tree | 6c325a8e053f1ec30ae4e6a2684fffea851a38b2 | |
parent | 42cc6bab16a6b451ab1b36e302100afcd95e6634 (diff) | |
download | busybox-w32-c8842213f5ad95b1b6e32d2db1dce5ce8c04ece9.tar.gz busybox-w32-c8842213f5ad95b1b6e32d2db1dce5ce8c04ece9.tar.bz2 busybox-w32-c8842213f5ad95b1b6e32d2db1dce5ce8c04ece9.zip |
top: fix "top -d 1" (bug 5144)
-rw-r--r-- | procps/top.c | 17 |
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) | |||
894 | unsigned lines, col; | 894 | unsigned lines, col; |
895 | int lines_rem; | 895 | int lines_rem; |
896 | unsigned interval; | 896 | unsigned interval; |
897 | char *sinterval; | 897 | char *str_interval, *str_iterations; |
898 | SKIP_FEATURE_TOPMEM(const) unsigned scan_mask = TOP_MASK; | 898 | SKIP_FEATURE_TOPMEM(const) unsigned scan_mask = TOP_MASK; |
899 | #if ENABLE_FEATURE_USE_TERMIOS | 899 | #if ENABLE_FEATURE_USE_TERMIOS |
900 | struct termios new_settings; | 900 | struct termios new_settings; |
@@ -917,10 +917,19 @@ int top_main(int argc UNUSED_PARAM, char **argv) | |||
917 | #endif | 917 | #endif |
918 | 918 | ||
919 | /* all args are options; -n NUM */ | 919 | /* all args are options; -n NUM */ |
920 | opt_complementary = "-:n+"; | 920 | opt_complementary = "-"; |
921 | if (getopt32(argv, "d:n:b", &sinterval, &iterations) & OPT_d) { | 921 | col = getopt32(argv, "d:n:b", &str_interval, &str_iterations); |
922 | if (col & OPT_d) { | ||
923 | /* work around for "-d 1" -> "-d -1" done by getopt32 */ | ||
924 | if (str_interval[0] == '-') | ||
925 | str_interval++; | ||
922 | /* Need to limit it to not overflow poll timeout */ | 926 | /* Need to limit it to not overflow poll timeout */ |
923 | interval = xatou16(sinterval); /* -d */ | 927 | interval = xatou16(str_interval); |
928 | } | ||
929 | if (col & OPT_n) { | ||
930 | if (str_iterations[0] == '-') | ||
931 | str_iterations++; | ||
932 | iterations = xatou(str_iterations); | ||
924 | } | 933 | } |
925 | 934 | ||
926 | /* change to /proc */ | 935 | /* change to /proc */ |