PSSCAN_NICE = (1 << 20) * ENABLE_FEATURE_PS_ADDITIONAL_COLUMNS,
PSSCAN_RUIDGID = (1 << 21) * ENABLE_FEATURE_PS_ADDITIONAL_COLUMNS,
PSSCAN_TASKS = (1 << 22) * ENABLE_FEATURE_SHOW_THREADS,
- /* These are all retrieved from proc/NN/stat in one go: */
- PSSCAN_STAT = PSSCAN_PPID | PSSCAN_PGID | PSSCAN_SID
- /**/ | PSSCAN_COMM | PSSCAN_STATE
- /**/ | PSSCAN_VSZ | PSSCAN_RSS
- /**/ | PSSCAN_STIME | PSSCAN_UTIME | PSSCAN_START_TIME
- /**/ | PSSCAN_TTY | PSSCAN_NICE
- /**/ | PSSCAN_CPU
};
//procps_status_t* alloc_procps_scan(void) FAST_FUNC;
void free_procps_scan(procps_status_t* sp) FAST_FUNC;
* TIME The cumulative execution time for the process
* CMD The command name; the full command line is shown with -f
*/
-#if ENABLE_SELINUX
-# define SELINUX_O_PREFIX "label,"
-# define DEFAULT_O_STR (SELINUX_O_PREFIX "pid,user" IF_FEATURE_PS_TIME(",time") ",args")
-#else
-# define DEFAULT_O_STR ("pid,user" IF_FEATURE_PS_TIME(",time") ",args")
-#endif
-
typedef struct {
uint16_t width;
char name6[6];
unsigned kernel_HZ;
unsigned long long seconds_since_boot;
#endif
- char default_o[sizeof(DEFAULT_O_STR)];
} FIX_ALIASING;
#define G (*(struct globals*)&bb_common_bufsiz1)
#define out (G.out )
#define terminal_width (G.terminal_width )
#define kernel_HZ (G.kernel_HZ )
#define seconds_since_boot (G.seconds_since_boot)
-#define default_o (G.default_o )
#define INIT_G() do { } while (0)
#if ENABLE_FEATURE_PS_TIME
safe_strncpy(buf, ps->comm, size+1);
}
-static void func_stat(char *buf, int size, const procps_status_t *ps)
+static void func_state(char *buf, int size, const procps_status_t *ps)
{
safe_strncpy(buf, ps->state, size+1);
}
{ 6 , "tty" ,"TT" ,func_tty ,PSSCAN_TTY },
{ 4 , "vsz" ,"VSZ" ,func_vsz ,PSSCAN_VSZ },
/* Not mandated, but useful: */
- { 4 , "stat" ,"STAT" ,func_stat ,PSSCAN_STAT },
+ { 4 , "stat" ,"STAT" ,func_state ,PSSCAN_STATE },
{ 4 , "rss" ,"RSS" ,func_rss ,PSSCAN_RSS },
#if ENABLE_SELINUX
{ 35 , "label" ,"LABEL" ,func_label ,PSSCAN_CONTEXT },
printf("%.*s\n", terminal_width, buffer);
}
+#if ENABLE_SELINUX
+# define SELINUX_O_PREFIX "label,"
+# define DEFAULT_O_STR (SELINUX_O_PREFIX "pid,user" IF_FEATURE_PS_TIME(",time") ",args")
+#else
+# define DEFAULT_O_STR ("pid,user" IF_FEATURE_PS_TIME(",time") ",args")
+#endif
+
int ps_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int ps_main(int argc UNUSED_PARAM, char **argv)
{
procps_status_t *p;
llist_t* opt_o = NULL;
+ char default_o[sizeof(DEFAULT_O_STR)];
int opt;
enum {
OPT_Z = (1 << 0),
parse_o(llist_pop(&opt_o));
} while (opt_o);
} else {
- /* Below: parse_o() needs char*, NOT const char*... */
+ /* Below: parse_o() needs char*, NOT const char*, can't give it default_o */
#if ENABLE_SELINUX
if (!(opt & OPT_Z) || !is_selinux_enabled()) {
/* no -Z or no SELinux: do not show LABEL */