diff options
author | Ron Yorston <rmy@pobox.com> | 2012-03-22 13:15:08 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2012-03-22 13:15:08 +0000 |
commit | c0d4367d6b581eb5989c02815880cf0fa2851ae8 (patch) | |
tree | 868c266e627e2d7f65ba5a4d5f98a1c421453181 /procps | |
parent | f6bad5ef766b0447158e3de2f55c35f1f6cecb58 (diff) | |
parent | da4441c44f6efccb6f7b7588404d9c6bfb7b6af8 (diff) | |
download | busybox-w32-c0d4367d6b581eb5989c02815880cf0fa2851ae8.tar.gz busybox-w32-c0d4367d6b581eb5989c02815880cf0fa2851ae8.tar.bz2 busybox-w32-c0d4367d6b581eb5989c02815880cf0fa2851ae8.zip |
Merge commit 'da4441c44f6efccb6f7b7588404d9c6bfb7b6af8' into merge
Conflicts:
libbb/vfork_daemon_rexec.c
networking/wget.c
procps/ps.c
Diffstat (limited to 'procps')
-rw-r--r-- | procps/kill.c | 25 | ||||
-rw-r--r-- | procps/ps.c | 44 | ||||
-rw-r--r-- | procps/pstree.c | 2 |
3 files changed, 58 insertions, 13 deletions
diff --git a/procps/kill.c b/procps/kill.c index 3da39f030..e6f27af50 100644 --- a/procps/kill.c +++ b/procps/kill.c | |||
@@ -208,9 +208,27 @@ int kill_main(int argc, char **argv) | |||
208 | 208 | ||
209 | /* Looks like they want to do a kill. Do that */ | 209 | /* Looks like they want to do a kill. Do that */ |
210 | while (arg) { | 210 | while (arg) { |
211 | /* Support shell 'space' trick */ | 211 | #if ENABLE_ASH || ENABLE_HUSH |
212 | if (arg[0] == ' ') | 212 | /* |
213 | arg++; | 213 | * We need to support shell's "hack formats" of |
214 | * " -PRGP_ID" (yes, with a leading space) | ||
215 | * and " PID1 PID2 PID3" (with degenerate case "") | ||
216 | */ | ||
217 | while (*arg != '\0') { | ||
218 | char *end; | ||
219 | if (*arg == ' ') | ||
220 | arg++; | ||
221 | pid = bb_strtoi(arg, &end, 10); | ||
222 | if (errno && (errno != EINVAL || *end != ' ')) { | ||
223 | bb_error_msg("invalid number '%s'", arg); | ||
224 | errors++; | ||
225 | } else if (kill(pid, signo) != 0) { | ||
226 | bb_perror_msg("can't kill pid %d", (int)pid); | ||
227 | errors++; | ||
228 | } | ||
229 | arg = end; /* can only point to ' ' or '\0' now */ | ||
230 | } | ||
231 | #else | ||
214 | pid = bb_strtoi(arg, NULL, 10); | 232 | pid = bb_strtoi(arg, NULL, 10); |
215 | if (errno) { | 233 | if (errno) { |
216 | bb_error_msg("invalid number '%s'", arg); | 234 | bb_error_msg("invalid number '%s'", arg); |
@@ -219,6 +237,7 @@ int kill_main(int argc, char **argv) | |||
219 | bb_perror_msg("can't kill pid %d", (int)pid); | 237 | bb_perror_msg("can't kill pid %d", (int)pid); |
220 | errors++; | 238 | errors++; |
221 | } | 239 | } |
240 | #endif | ||
222 | arg = *++argv; | 241 | arg = *++argv; |
223 | } | 242 | } |
224 | return errors; | 243 | return errors; |
diff --git a/procps/ps.c b/procps/ps.c index 3f7437b38..c54618248 100644 --- a/procps/ps.c +++ b/procps/ps.c | |||
@@ -18,17 +18,36 @@ enum { MAX_WIDTH = 2*1024 }; | |||
18 | 18 | ||
19 | #include <sys/times.h> /* for times() */ | 19 | #include <sys/times.h> /* for times() */ |
20 | #ifndef AT_CLKTCK | 20 | #ifndef AT_CLKTCK |
21 | #define AT_CLKTCK 17 | 21 | # define AT_CLKTCK 17 |
22 | #endif | 22 | #endif |
23 | 23 | ||
24 | 24 | /* TODO: | |
25 | * http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ps.html | ||
26 | * specifies (for XSI-conformant systems) following default columns | ||
27 | * (l and f mark columns shown with -l and -f respectively): | ||
28 | * F l Flags (octal and additive) associated with the process (??) | ||
29 | * S l The state of the process | ||
30 | * UID f,l The user ID; the login name is printed with -f | ||
31 | * PID The process ID | ||
32 | * PPID f,l The parent process | ||
33 | * C f,l Processor utilization | ||
34 | * PRI l The priority of the process; higher numbers mean lower priority | ||
35 | * NI l Nice value | ||
36 | * ADDR l The address of the process | ||
37 | * SZ l The size in blocks of the core image of the process | ||
38 | * WCHAN l The event for which the process is waiting or sleeping | ||
39 | * STIME f Starting time of the process | ||
40 | * TTY The controlling terminal for the process | ||
41 | * TIME The cumulative execution time for the process | ||
42 | * CMD The command name; the full command line is shown with -f | ||
43 | */ | ||
25 | #if ENABLE_SELINUX | 44 | #if ENABLE_SELINUX |
26 | #define SELINUX_O_PREFIX "label," | 45 | # define SELINUX_O_PREFIX "label," |
27 | #define DEFAULT_O_STR (SELINUX_O_PREFIX "pid,user" IF_FEATURE_PS_TIME(",time") ",args") | 46 | # define DEFAULT_O_STR (SELINUX_O_PREFIX "pid,user" IF_FEATURE_PS_TIME(",time") ",args") |
28 | #elif ENABLE_PLATFORM_MINGW32 | 47 | #elif ENABLE_PLATFORM_MINGW32 |
29 | #define DEFAULT_O_STR ("pid,comm") | 48 | # define DEFAULT_O_STR ("pid,comm") |
30 | #else | 49 | #else |
31 | #define DEFAULT_O_STR ("pid,user" IF_FEATURE_PS_TIME(",time") ",args") | 50 | # define DEFAULT_O_STR ("pid,user" IF_FEATURE_PS_TIME(",time") ",args") |
32 | #endif | 51 | #endif |
33 | 52 | ||
34 | typedef struct { | 53 | typedef struct { |
@@ -70,7 +89,8 @@ static ptrdiff_t find_elf_note(ptrdiff_t findme) | |||
70 | { | 89 | { |
71 | ptrdiff_t *ep = (ptrdiff_t *) environ; | 90 | ptrdiff_t *ep = (ptrdiff_t *) environ; |
72 | 91 | ||
73 | while (*ep++); | 92 | while (*ep++) |
93 | continue; | ||
74 | while (*ep) { | 94 | while (*ep) { |
75 | if (ep[0] == findme) { | 95 | if (ep[0] == findme) { |
76 | return ep[1]; | 96 | return ep[1]; |
@@ -186,6 +206,11 @@ static void func_comm(char *buf, int size, const procps_status_t *ps) | |||
186 | safe_strncpy(buf, ps->comm, size+1); | 206 | safe_strncpy(buf, ps->comm, size+1); |
187 | } | 207 | } |
188 | 208 | ||
209 | static void func_stat(char *buf, int size, const procps_status_t *ps) | ||
210 | { | ||
211 | safe_strncpy(buf, ps->state, size+1); | ||
212 | } | ||
213 | |||
189 | static void func_args(char *buf, int size, const procps_status_t *ps) | 214 | static void func_args(char *buf, int size, const procps_status_t *ps) |
190 | { | 215 | { |
191 | read_cmdline(buf, size+1, ps->pid, ps->comm); | 216 | read_cmdline(buf, size+1, ps->pid, ps->comm); |
@@ -302,7 +327,7 @@ static void func_pcpu(char *buf, int size, const procps_status_t *ps) | |||
302 | */ | 327 | */ |
303 | 328 | ||
304 | static const ps_out_t out_spec[] = { | 329 | static const ps_out_t out_spec[] = { |
305 | // Mandated by POSIX: | 330 | /* Mandated by http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ps.html: */ |
306 | #if !ENABLE_PLATFORM_MINGW32 | 331 | #if !ENABLE_PLATFORM_MINGW32 |
307 | { 8 , "user" ,"USER" ,func_user ,PSSCAN_UIDGID }, | 332 | { 8 , "user" ,"USER" ,func_user ,PSSCAN_UIDGID }, |
308 | { 8 , "group" ,"GROUP" ,func_group ,PSSCAN_UIDGID }, | 333 | { 8 , "group" ,"GROUP" ,func_group ,PSSCAN_UIDGID }, |
@@ -331,7 +356,8 @@ static const ps_out_t out_spec[] = { | |||
331 | #if !ENABLE_PLATFORM_MINGW32 | 356 | #if !ENABLE_PLATFORM_MINGW32 |
332 | { 6 , "tty" ,"TT" ,func_tty ,PSSCAN_TTY }, | 357 | { 6 , "tty" ,"TT" ,func_tty ,PSSCAN_TTY }, |
333 | { 4 , "vsz" ,"VSZ" ,func_vsz ,PSSCAN_VSZ }, | 358 | { 4 , "vsz" ,"VSZ" ,func_vsz ,PSSCAN_VSZ }, |
334 | // Not mandated by POSIX, but useful: | 359 | /* Not mandated, but useful: */ |
360 | { 4 , "stat" ,"STAT" ,func_stat ,PSSCAN_STAT }, | ||
335 | { 4 , "rss" ,"RSS" ,func_rss ,PSSCAN_RSS }, | 361 | { 4 , "rss" ,"RSS" ,func_rss ,PSSCAN_RSS }, |
336 | #endif | 362 | #endif |
337 | #if ENABLE_SELINUX | 363 | #if ENABLE_SELINUX |
diff --git a/procps/pstree.c b/procps/pstree.c index ddf5dba59..4cd8cb458 100644 --- a/procps/pstree.c +++ b/procps/pstree.c | |||
@@ -76,7 +76,7 @@ struct globals { | |||
76 | }; | 76 | }; |
77 | #define G (*ptr_to_globals) | 77 | #define G (*ptr_to_globals) |
78 | #define INIT_G() do { \ | 78 | #define INIT_G() do { \ |
79 | SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ | 79 | SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ |
80 | } while (0) | 80 | } while (0) |
81 | 81 | ||
82 | 82 | ||