aboutsummaryrefslogtreecommitdiff
path: root/procps/ps.c
diff options
context:
space:
mode:
Diffstat (limited to 'procps/ps.c')
-rw-r--r--procps/ps.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/procps/ps.c b/procps/ps.c
index 5b521aebd..329576eb8 100644
--- a/procps/ps.c
+++ b/procps/ps.c
@@ -120,7 +120,7 @@ enum { MAX_WIDTH = 2*1024 };
120#if ENABLE_FEATURE_PS_TIME || ENABLE_FEATURE_PS_LONG 120#if ENABLE_FEATURE_PS_TIME || ENABLE_FEATURE_PS_LONG
121static unsigned long get_uptime(void) 121static unsigned long get_uptime(void)
122{ 122{
123#ifdef __linux__ 123#if defined __linux__ || ENABLE_PLATFORM_MINGW32
124 struct sysinfo info; 124 struct sysinfo info;
125 if (sysinfo(&info) < 0) 125 if (sysinfo(&info) < 0)
126 return 0; 126 return 0;
@@ -237,10 +237,12 @@ static void func_comm(char *buf, int size, const procps_status_t *ps)
237 safe_strncpy(buf, ps->comm, size+1); 237 safe_strncpy(buf, ps->comm, size+1);
238} 238}
239 239
240#if !ENABLE_PLATFORM_MINGW32
240static void func_state(char *buf, int size, const procps_status_t *ps) 241static void func_state(char *buf, int size, const procps_status_t *ps)
241{ 242{
242 safe_strncpy(buf, ps->state, size+1); 243 safe_strncpy(buf, ps->state, size+1);
243} 244}
245#endif
244 246
245static void func_args(char *buf, int size, const procps_status_t *ps) 247static void func_args(char *buf, int size, const procps_status_t *ps)
246{ 248{
@@ -257,6 +259,7 @@ static void func_ppid(char *buf, int size, const procps_status_t *ps)
257 sprintf(buf, "%*u", size, ps->ppid); 259 sprintf(buf, "%*u", size, ps->ppid);
258} 260}
259 261
262#if !ENABLE_PLATFORM_MINGW32
260static void func_pgid(char *buf, int size, const procps_status_t *ps) 263static void func_pgid(char *buf, int size, const procps_status_t *ps)
261{ 264{
262 sprintf(buf, "%*u", size, ps->pgid); 265 sprintf(buf, "%*u", size, ps->pgid);
@@ -293,6 +296,7 @@ static void func_tty(char *buf, int size, const procps_status_t *ps)
293 if (ps->tty_major) /* tty field of "0" means "no tty" */ 296 if (ps->tty_major) /* tty field of "0" means "no tty" */
294 snprintf(buf, size+1, "%u,%u", ps->tty_major, ps->tty_minor); 297 snprintf(buf, size+1, "%u,%u", ps->tty_major, ps->tty_minor);
295} 298}
299#endif
296 300
297#if ENABLE_FEATURE_PS_ADDITIONAL_COLUMNS 301#if ENABLE_FEATURE_PS_ADDITIONAL_COLUMNS
298static void func_rgroup(char *buf, int size, const procps_status_t *ps) 302static void func_rgroup(char *buf, int size, const procps_status_t *ps)
@@ -379,11 +383,17 @@ static const ps_out_t out_spec[] ALIGN_PTR = {
379/* Mandated by http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ps.html: */ 383/* Mandated by http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ps.html: */
380 { 8 , "user" ,"USER" ,func_user ,PSSCAN_UIDGID }, 384 { 8 , "user" ,"USER" ,func_user ,PSSCAN_UIDGID },
381 { 8 , "group" ,"GROUP" ,func_group ,PSSCAN_UIDGID }, 385 { 8 , "group" ,"GROUP" ,func_group ,PSSCAN_UIDGID },
386#if ENABLE_PLATFORM_MINGW32
387 { COMM_LEN , "comm" ,"COMMAND",func_comm ,PSSCAN_COMM },
388#else
382 { 16 , "comm" ,"COMMAND",func_comm ,PSSCAN_COMM }, 389 { 16 , "comm" ,"COMMAND",func_comm ,PSSCAN_COMM },
390#endif
383 { MAX_WIDTH , "args" ,"COMMAND",func_args ,PSSCAN_COMM }, 391 { MAX_WIDTH , "args" ,"COMMAND",func_args ,PSSCAN_COMM },
384 { 5 , "pid" ,"PID" ,func_pid ,PSSCAN_PID }, 392 { 5 , "pid" ,"PID" ,func_pid ,PSSCAN_PID },
385 { 5 , "ppid" ,"PPID" ,func_ppid ,PSSCAN_PPID }, 393 { 5 , "ppid" ,"PPID" ,func_ppid ,PSSCAN_PPID },
394#if !ENABLE_PLATFORM_MINGW32
386 { 5 , "pgid" ,"PGID" ,func_pgid ,PSSCAN_PGID }, 395 { 5 , "pgid" ,"PGID" ,func_pgid ,PSSCAN_PGID },
396#endif
387#if ENABLE_FEATURE_PS_TIME 397#if ENABLE_FEATURE_PS_TIME
388 { sizeof("ELAPSED")-1, "etime" ,"ELAPSED",func_etime ,PSSCAN_START_TIME }, 398 { sizeof("ELAPSED")-1, "etime" ,"ELAPSED",func_etime ,PSSCAN_START_TIME },
389#endif 399#endif
@@ -396,12 +406,14 @@ static const ps_out_t out_spec[] ALIGN_PTR = {
396#if ENABLE_FEATURE_PS_TIME 406#if ENABLE_FEATURE_PS_TIME
397 { 5 , "time" ,"TIME" ,func_time ,PSSCAN_STIME | PSSCAN_UTIME }, 407 { 5 , "time" ,"TIME" ,func_time ,PSSCAN_STIME | PSSCAN_UTIME },
398#endif 408#endif
409#if !ENABLE_PLATFORM_MINGW32
399 { 6 , "tty" ,"TT" ,func_tty ,PSSCAN_TTY }, 410 { 6 , "tty" ,"TT" ,func_tty ,PSSCAN_TTY },
400 { 4 , "vsz" ,"VSZ" ,func_vsz ,PSSCAN_VSZ }, 411 { 4 , "vsz" ,"VSZ" ,func_vsz ,PSSCAN_VSZ },
401/* Not mandated, but useful: */ 412/* Not mandated, but useful: */
402 { 5 , "sid" ,"SID" ,func_sid ,PSSCAN_SID }, 413 { 5 , "sid" ,"SID" ,func_sid ,PSSCAN_SID },
403 { 4 , "stat" ,"STAT" ,func_state ,PSSCAN_STATE }, 414 { 4 , "stat" ,"STAT" ,func_state ,PSSCAN_STATE },
404 { 4 , "rss" ,"RSS" ,func_rss ,PSSCAN_RSS }, 415 { 4 , "rss" ,"RSS" ,func_rss ,PSSCAN_RSS },
416#endif
405#if ENABLE_SELINUX 417#if ENABLE_SELINUX
406 { 35 , "label" ,"LABEL" ,func_label ,PSSCAN_CONTEXT }, 418 { 35 , "label" ,"LABEL" ,func_label ,PSSCAN_CONTEXT },
407#endif 419#endif
@@ -544,6 +556,8 @@ static void format_process(const procps_status_t *ps)
544#if ENABLE_SELINUX 556#if ENABLE_SELINUX
545# define SELINUX_O_PREFIX "label," 557# define SELINUX_O_PREFIX "label,"
546# define DEFAULT_O_STR (SELINUX_O_PREFIX "pid,user" IF_FEATURE_PS_TIME(",time") ",args") 558# define DEFAULT_O_STR (SELINUX_O_PREFIX "pid,user" IF_FEATURE_PS_TIME(",time") ",args")
559#elif ENABLE_PLATFORM_MINGW32
560# define DEFAULT_O_STR ("pid,ppid,user" IF_FEATURE_PS_TIME(",time,etime") ",args")
547#else 561#else
548# define DEFAULT_O_STR ("pid,user" IF_FEATURE_PS_TIME(",time") ",args") 562# define DEFAULT_O_STR ("pid,user" IF_FEATURE_PS_TIME(",time") ",args")
549#endif 563#endif