summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko2017-02-02 13:04:30 +0100
committerDenys Vlasenko2017-02-02 13:04:30 +0100
commitb6871c1965af0eb87123e13f5d81ec0c9b801b71 (patch)
tree6c3d9145cf4073b8016eeccf2232e1b165a8388e
parentb1d6a2c6247bae0b9f1903ba0e0d16c56f4ef556 (diff)
downloadbusybox-b6871c1965af0eb87123e13f5d81ec0c9b801b71.zip
busybox-b6871c1965af0eb87123e13f5d81ec0c9b801b71.tar.gz
ps: avoid -o stat to contain spaces. Closes 9631
function old new delta procps_scan 1227 1236 +9 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--libbb/procps.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/libbb/procps.c b/libbb/procps.c
index 4edc54d..b52c0f5 100644
--- a/libbb/procps.c
+++ b/libbb/procps.c
@@ -370,6 +370,7 @@ procps_status_t* FAST_FUNC procps_scan(procps_status_t* sp, int flags)
| PSSCAN_TTY | PSSCAN_NICE
| PSSCAN_CPU)
) {
+ int s_idx;
char *cp, *comm1;
int tty;
#if !ENABLE_FEATURE_FAST_TOP
@@ -468,17 +469,20 @@ procps_status_t* FAST_FUNC procps_scan(procps_status_t* sp, int flags)
#if ENABLE_FEATURE_PS_ADDITIONAL_COLUMNS
sp->niceness = tasknice;
#endif
-
- if (sp->vsz == 0 && sp->state[0] != 'Z')
+ sp->state[1] = ' ';
+ sp->state[2] = ' ';
+ s_idx = 1;
+ if (sp->vsz == 0 && sp->state[0] != 'Z') {
+ /* not sure what the purpose of this flag */
sp->state[1] = 'W';
- else
- sp->state[1] = ' ';
- if (tasknice < 0)
- sp->state[2] = '<';
- else if (tasknice) /* > 0 */
- sp->state[2] = 'N';
- else
- sp->state[2] = ' ';
+ s_idx = 2;
+ }
+ if (tasknice != 0) {
+ if (tasknice < 0)
+ sp->state[s_idx] = '<';
+ else /* > 0 */
+ sp->state[s_idx] = 'N';
+ }
}
#if ENABLE_FEATURE_TOPMEM