008-ps.patch 2.9 KB

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