1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
--- busybox-1.17.2.orig/procps/ps.c 2010-08-23 02:44:35.000000000 +0200
+++ busybox-1.17.2/procps/ps.c 2010-11-27 23:47:59.000000000 +0100
@@ -14,8 +14,6 @@
/* Absolute maximum on output line length */
enum { MAX_WIDTH = 2*1024 };
-#if ENABLE_DESKTOP
-
#include <sys/times.h> /* for times() */
#ifndef AT_CLKTCK
#define AT_CLKTCK 17
@@ -544,98 +542,3 @@ int ps_main(int argc UNUSED_PARAM, char
return EXIT_SUCCESS;
}
-
-
-#else /* !ENABLE_DESKTOP */
-
-
-int ps_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int ps_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
-{
- procps_status_t *p;
- int psscan_flags = PSSCAN_PID | PSSCAN_UIDGID
- | PSSCAN_STATE | PSSCAN_VSZ | PSSCAN_COMM;
- unsigned terminal_width IF_NOT_FEATURE_PS_WIDE(= 79);
- enum {
- OPT_Z = (1 << 0) * ENABLE_SELINUX,
- OPT_T = (1 << ENABLE_SELINUX) * ENABLE_FEATURE_SHOW_THREADS,
- };
- int opts = 0;
- /* If we support any options, parse argv */
-#if ENABLE_SELINUX || ENABLE_FEATURE_SHOW_THREADS || ENABLE_FEATURE_PS_WIDE
-# if ENABLE_FEATURE_PS_WIDE
- /* -w is a bit complicated */
- int w_count = 0;
- opt_complementary = "-:ww";
- opts = getopt32(argv, IF_SELINUX("Z")IF_FEATURE_SHOW_THREADS("T")"w", &w_count);
- /* if w is given once, GNU ps sets the width to 132,
- * if w is given more than once, it is "unlimited"
- */
- if (w_count) {
- terminal_width = (w_count == 1) ? 132 : MAX_WIDTH;
- } else {
- get_terminal_width_height(0, &terminal_width, NULL);
- /* Go one less... */
- if (--terminal_width > MAX_WIDTH)
- terminal_width = MAX_WIDTH;
- }
-# else
- /* -w is not supported, only -Z and/or -T */
- opt_complementary = "-";
- opts = getopt32(argv, IF_SELINUX("Z")IF_FEATURE_SHOW_THREADS("T"));
-# endif
-#endif
-
-#if ENABLE_SELINUX
- if ((opts & OPT_Z) && is_selinux_enabled()) {
- psscan_flags = PSSCAN_PID | PSSCAN_CONTEXT
- | PSSCAN_STATE | PSSCAN_COMM;
- puts(" PID CONTEXT STAT COMMAND");
- } else
-#endif
- {
- puts(" PID USER VSZ STAT COMMAND");
- }
- if (opts & OPT_T) {
- psscan_flags |= PSSCAN_TASKS;
- }
-
- p = NULL;
- while ((p = procps_scan(p, psscan_flags)) != NULL) {
- int len;
-#if ENABLE_SELINUX
- if (psscan_flags & PSSCAN_CONTEXT) {
- len = printf("%5u %-32.32s %s ",
- p->pid,
- p->context ? p->context : "unknown",
- p->state);
- } else
-#endif
- {
- const char *user = get_cached_username(p->uid);
- //if (p->vsz == 0)
- // len = printf("%5u %-8.8s %s ",
- // p->pid, user, p->state);
- //else
- {
- char buf6[6];
- smart_ulltoa5(p->vsz, buf6, " mgtpezy");
- buf6[5] = '\0';
- len = printf("%5u %-8.8s %s %s ",
- p->pid, user, buf6, p->state);
- }
- }
-
- {
- int sz = terminal_width - len;
- char buf[sz + 1];
- read_cmdline(buf, sz, p->pid, p->comm);
- puts(buf);
- }
- }
- if (ENABLE_FEATURE_CLEAN_UP)
- clear_username_cache();
- return EXIT_SUCCESS;
-}
-
-#endif /* !ENABLE_DESKTOP */
|