diff options
author | Ron Yorston <rmy@pobox.com> | 2012-03-22 15:41:00 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2012-03-22 15:41:00 +0000 |
commit | 1118c95535ea51961437089fc3dece5ab4ea7e1b (patch) | |
tree | 1515bd2376a6d6c5123791662307ce2ed90cdf36 /procps/ps.c | |
parent | 0d8b2c4a929ea9d3ac37499319fe0d8e7941a0c2 (diff) | |
parent | 066f39956641300c1e5c6bfe6c11a115cea3e2cf (diff) | |
download | busybox-w32-1118c95535ea51961437089fc3dece5ab4ea7e1b.tar.gz busybox-w32-1118c95535ea51961437089fc3dece5ab4ea7e1b.tar.bz2 busybox-w32-1118c95535ea51961437089fc3dece5ab4ea7e1b.zip |
Merge commit '066f39956641300c1e5c6bfe6c11a115cea3e2cf' into merge
Conflicts:
procps/ps.c
Diffstat (limited to 'procps/ps.c')
-rw-r--r-- | procps/ps.c | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/procps/ps.c b/procps/ps.c index 41e1b1e87..41124279d 100644 --- a/procps/ps.c +++ b/procps/ps.c | |||
@@ -15,7 +15,6 @@ | |||
15 | //usage: "[-o COL1,COL2=HEADER]" IF_FEATURE_SHOW_THREADS(" [-T]") | 15 | //usage: "[-o COL1,COL2=HEADER]" IF_FEATURE_SHOW_THREADS(" [-T]") |
16 | //usage:#define ps_full_usage "\n\n" | 16 | //usage:#define ps_full_usage "\n\n" |
17 | //usage: "Show list of processes\n" | 17 | //usage: "Show list of processes\n" |
18 | //usage: "\nOptions:" | ||
19 | //usage: "\n -o COL1,COL2=HEADER Select columns for display" | 18 | //usage: "\n -o COL1,COL2=HEADER Select columns for display" |
20 | //usage: IF_FEATURE_SHOW_THREADS( | 19 | //usage: IF_FEATURE_SHOW_THREADS( |
21 | //usage: "\n -T Show threads" | 20 | //usage: "\n -T Show threads" |
@@ -26,7 +25,7 @@ | |||
26 | //usage:#if !ENABLE_SELINUX && !ENABLE_FEATURE_PS_WIDE | 25 | //usage:#if !ENABLE_SELINUX && !ENABLE_FEATURE_PS_WIDE |
27 | //usage:#define USAGE_PS "\nThis version of ps accepts no options" | 26 | //usage:#define USAGE_PS "\nThis version of ps accepts no options" |
28 | //usage:#else | 27 | //usage:#else |
29 | //usage:#define USAGE_PS "\nOptions:" | 28 | //usage:#define USAGE_PS "" |
30 | //usage:#endif | 29 | //usage:#endif |
31 | //usage: | 30 | //usage: |
32 | //usage:#define ps_trivial_usage | 31 | //usage:#define ps_trivial_usage |
@@ -88,15 +87,6 @@ enum { MAX_WIDTH = 2*1024 }; | |||
88 | * TIME The cumulative execution time for the process | 87 | * TIME The cumulative execution time for the process |
89 | * CMD The command name; the full command line is shown with -f | 88 | * CMD The command name; the full command line is shown with -f |
90 | */ | 89 | */ |
91 | #if ENABLE_SELINUX | ||
92 | # define SELINUX_O_PREFIX "label," | ||
93 | # define DEFAULT_O_STR (SELINUX_O_PREFIX "pid,user" IF_FEATURE_PS_TIME(",time") ",args") | ||
94 | #elif ENABLE_PLATFORM_MINGW32 | ||
95 | # define DEFAULT_O_STR ("pid,comm") | ||
96 | #else | ||
97 | # define DEFAULT_O_STR ("pid,user" IF_FEATURE_PS_TIME(",time") ",args") | ||
98 | #endif | ||
99 | |||
100 | typedef struct { | 90 | typedef struct { |
101 | uint16_t width; | 91 | uint16_t width; |
102 | char name6[6]; | 92 | char name6[6]; |
@@ -116,7 +106,6 @@ struct globals { | |||
116 | unsigned kernel_HZ; | 106 | unsigned kernel_HZ; |
117 | unsigned long long seconds_since_boot; | 107 | unsigned long long seconds_since_boot; |
118 | #endif | 108 | #endif |
119 | char default_o[sizeof(DEFAULT_O_STR)]; | ||
120 | } FIX_ALIASING; | 109 | } FIX_ALIASING; |
121 | #define G (*(struct globals*)&bb_common_bufsiz1) | 110 | #define G (*(struct globals*)&bb_common_bufsiz1) |
122 | #define out (G.out ) | 111 | #define out (G.out ) |
@@ -127,7 +116,6 @@ struct globals { | |||
127 | #define terminal_width (G.terminal_width ) | 116 | #define terminal_width (G.terminal_width ) |
128 | #define kernel_HZ (G.kernel_HZ ) | 117 | #define kernel_HZ (G.kernel_HZ ) |
129 | #define seconds_since_boot (G.seconds_since_boot) | 118 | #define seconds_since_boot (G.seconds_since_boot) |
130 | #define default_o (G.default_o ) | ||
131 | #define INIT_G() do { } while (0) | 119 | #define INIT_G() do { } while (0) |
132 | 120 | ||
133 | #if ENABLE_FEATURE_PS_TIME | 121 | #if ENABLE_FEATURE_PS_TIME |
@@ -253,7 +241,7 @@ static void func_comm(char *buf, int size, const procps_status_t *ps) | |||
253 | safe_strncpy(buf, ps->comm, size+1); | 241 | safe_strncpy(buf, ps->comm, size+1); |
254 | } | 242 | } |
255 | 243 | ||
256 | static void func_stat(char *buf, int size, const procps_status_t *ps) | 244 | static void func_state(char *buf, int size, const procps_status_t *ps) |
257 | { | 245 | { |
258 | safe_strncpy(buf, ps->state, size+1); | 246 | safe_strncpy(buf, ps->state, size+1); |
259 | } | 247 | } |
@@ -404,7 +392,7 @@ static const ps_out_t out_spec[] = { | |||
404 | { 6 , "tty" ,"TT" ,func_tty ,PSSCAN_TTY }, | 392 | { 6 , "tty" ,"TT" ,func_tty ,PSSCAN_TTY }, |
405 | { 4 , "vsz" ,"VSZ" ,func_vsz ,PSSCAN_VSZ }, | 393 | { 4 , "vsz" ,"VSZ" ,func_vsz ,PSSCAN_VSZ }, |
406 | /* Not mandated, but useful: */ | 394 | /* Not mandated, but useful: */ |
407 | { 4 , "stat" ,"STAT" ,func_stat ,PSSCAN_STAT }, | 395 | { 4 , "stat" ,"STAT" ,func_state ,PSSCAN_STATE }, |
408 | { 4 , "rss" ,"RSS" ,func_rss ,PSSCAN_RSS }, | 396 | { 4 , "rss" ,"RSS" ,func_rss ,PSSCAN_RSS }, |
409 | #endif | 397 | #endif |
410 | #if ENABLE_SELINUX | 398 | #if ENABLE_SELINUX |
@@ -542,11 +530,21 @@ static void format_process(const procps_status_t *ps) | |||
542 | printf("%.*s\n", terminal_width, buffer); | 530 | printf("%.*s\n", terminal_width, buffer); |
543 | } | 531 | } |
544 | 532 | ||
533 | #if ENABLE_SELINUX | ||
534 | # define SELINUX_O_PREFIX "label," | ||
535 | # define DEFAULT_O_STR (SELINUX_O_PREFIX "pid,user" IF_FEATURE_PS_TIME(",time") ",args") | ||
536 | #elif ENABLE_PLATFORM_MINGW32 | ||
537 | # define DEFAULT_O_STR ("pid,comm") | ||
538 | #else | ||
539 | # define DEFAULT_O_STR ("pid,user" IF_FEATURE_PS_TIME(",time") ",args") | ||
540 | #endif | ||
541 | |||
545 | int ps_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 542 | int ps_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
546 | int ps_main(int argc UNUSED_PARAM, char **argv) | 543 | int ps_main(int argc UNUSED_PARAM, char **argv) |
547 | { | 544 | { |
548 | procps_status_t *p; | 545 | procps_status_t *p; |
549 | llist_t* opt_o = NULL; | 546 | llist_t* opt_o = NULL; |
547 | char default_o[sizeof(DEFAULT_O_STR)]; | ||
550 | int opt; | 548 | int opt; |
551 | enum { | 549 | enum { |
552 | OPT_Z = (1 << 0), | 550 | OPT_Z = (1 << 0), |
@@ -584,7 +582,7 @@ int ps_main(int argc UNUSED_PARAM, char **argv) | |||
584 | parse_o(llist_pop(&opt_o)); | 582 | parse_o(llist_pop(&opt_o)); |
585 | } while (opt_o); | 583 | } while (opt_o); |
586 | } else { | 584 | } else { |
587 | /* Below: parse_o() needs char*, NOT const char*... */ | 585 | /* Below: parse_o() needs char*, NOT const char*, can't give it default_o */ |
588 | #if ENABLE_SELINUX | 586 | #if ENABLE_SELINUX |
589 | if (!(opt & OPT_Z) || !is_selinux_enabled()) { | 587 | if (!(opt & OPT_Z) || !is_selinux_enabled()) { |
590 | /* no -Z or no SELinux: do not show LABEL */ | 588 | /* no -Z or no SELinux: do not show LABEL */ |