123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- --- 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 */
|