aboutsummaryrefslogtreecommitdiff
path: root/procps/ps.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--procps/ps.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/procps/ps.c b/procps/ps.c
index e291ecd7e..902811f31 100644
--- a/procps/ps.c
+++ b/procps/ps.c
@@ -290,6 +290,7 @@ static unsigned get_kernel_HZ(void)
290 290
291/* Print value to buf, max size+1 chars (including trailing '\0') */ 291/* Print value to buf, max size+1 chars (including trailing '\0') */
292 292
293#if !ENABLE_PLATFORM_MINGW32
293static void func_user(char *buf, int size, const procps_status_t *ps) 294static void func_user(char *buf, int size, const procps_status_t *ps)
294{ 295{
295#if 1 296#if 1
@@ -313,12 +314,14 @@ static void func_group(char *buf, int size, const procps_status_t *ps)
313{ 314{
314 safe_strncpy(buf, get_cached_groupname(ps->gid), size+1); 315 safe_strncpy(buf, get_cached_groupname(ps->gid), size+1);
315} 316}
317#endif
316 318
317static void func_comm(char *buf, int size, const procps_status_t *ps) 319static void func_comm(char *buf, int size, const procps_status_t *ps)
318{ 320{
319 safe_strncpy(buf, ps->comm, size+1); 321 safe_strncpy(buf, ps->comm, size+1);
320} 322}
321 323
324#if !ENABLE_PLATFORM_MINGW32
322static void func_state(char *buf, int size, const procps_status_t *ps) 325static void func_state(char *buf, int size, const procps_status_t *ps)
323{ 326{
324 safe_strncpy(buf, ps->state, size+1); 327 safe_strncpy(buf, ps->state, size+1);
@@ -328,12 +331,14 @@ static void func_args(char *buf, int size, const procps_status_t *ps)
328{ 331{
329 read_cmdline(buf, size+1, ps->pid, ps->comm); 332 read_cmdline(buf, size+1, ps->pid, ps->comm);
330} 333}
334#endif
331 335
332static void func_pid(char *buf, int size, const procps_status_t *ps) 336static void func_pid(char *buf, int size, const procps_status_t *ps)
333{ 337{
334 sprintf(buf, "%*u", size, ps->pid); 338 sprintf(buf, "%*u", size, ps->pid);
335} 339}
336 340
341#if !ENABLE_PLATFORM_MINGW32
337static void func_ppid(char *buf, int size, const procps_status_t *ps) 342static void func_ppid(char *buf, int size, const procps_status_t *ps)
338{ 343{
339 sprintf(buf, "%*u", size, ps->ppid); 344 sprintf(buf, "%*u", size, ps->ppid);
@@ -370,6 +375,7 @@ static void func_tty(char *buf, int size, const procps_status_t *ps)
370 if (ps->tty_major) /* tty field of "0" means "no tty" */ 375 if (ps->tty_major) /* tty field of "0" means "no tty" */
371 snprintf(buf, size+1, "%u,%u", ps->tty_major, ps->tty_minor); 376 snprintf(buf, size+1, "%u,%u", ps->tty_major, ps->tty_minor);
372} 377}
378#endif
373 379
374#if ENABLE_FEATURE_PS_ADDITIONAL_COLUMNS 380#if ENABLE_FEATURE_PS_ADDITIONAL_COLUMNS
375 381
@@ -440,13 +446,19 @@ static void func_pcpu(char *buf, int size, const procps_status_t *ps)
440 446
441static const ps_out_t out_spec[] = { 447static const ps_out_t out_spec[] = {
442/* Mandated by http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ps.html: */ 448/* Mandated by http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ps.html: */
449#if !ENABLE_PLATFORM_MINGW32
443 { 8 , "user" ,"USER" ,func_user ,PSSCAN_UIDGID }, 450 { 8 , "user" ,"USER" ,func_user ,PSSCAN_UIDGID },
444 { 8 , "group" ,"GROUP" ,func_group ,PSSCAN_UIDGID }, 451 { 8 , "group" ,"GROUP" ,func_group ,PSSCAN_UIDGID },
452#endif
445 { 16 , "comm" ,"COMMAND",func_comm ,PSSCAN_COMM }, 453 { 16 , "comm" ,"COMMAND",func_comm ,PSSCAN_COMM },
454#if !ENABLE_PLATFORM_MINGW32
446 { MAX_WIDTH , "args" ,"COMMAND",func_args ,PSSCAN_COMM }, 455 { MAX_WIDTH , "args" ,"COMMAND",func_args ,PSSCAN_COMM },
456#endif
447 { 5 , "pid" ,"PID" ,func_pid ,PSSCAN_PID }, 457 { 5 , "pid" ,"PID" ,func_pid ,PSSCAN_PID },
458#if !ENABLE_PLATFORM_MINGW32
448 { 5 , "ppid" ,"PPID" ,func_ppid ,PSSCAN_PPID }, 459 { 5 , "ppid" ,"PPID" ,func_ppid ,PSSCAN_PPID },
449 { 5 , "pgid" ,"PGID" ,func_pgid ,PSSCAN_PGID }, 460 { 5 , "pgid" ,"PGID" ,func_pgid ,PSSCAN_PGID },
461#endif
450#if ENABLE_FEATURE_PS_TIME 462#if ENABLE_FEATURE_PS_TIME
451 { sizeof("ELAPSED")-1, "etime" ,"ELAPSED",func_etime ,PSSCAN_START_TIME }, 463 { sizeof("ELAPSED")-1, "etime" ,"ELAPSED",func_etime ,PSSCAN_START_TIME },
452#endif 464#endif
@@ -459,11 +471,13 @@ static const ps_out_t out_spec[] = {
459#if ENABLE_FEATURE_PS_TIME 471#if ENABLE_FEATURE_PS_TIME
460 { 6 , "time" ,"TIME" ,func_time ,PSSCAN_STIME | PSSCAN_UTIME }, 472 { 6 , "time" ,"TIME" ,func_time ,PSSCAN_STIME | PSSCAN_UTIME },
461#endif 473#endif
474#if !ENABLE_PLATFORM_MINGW32
462 { 6 , "tty" ,"TT" ,func_tty ,PSSCAN_TTY }, 475 { 6 , "tty" ,"TT" ,func_tty ,PSSCAN_TTY },
463 { 4 , "vsz" ,"VSZ" ,func_vsz ,PSSCAN_VSZ }, 476 { 4 , "vsz" ,"VSZ" ,func_vsz ,PSSCAN_VSZ },
464/* Not mandated, but useful: */ 477/* Not mandated, but useful: */
465 { 4 , "stat" ,"STAT" ,func_state ,PSSCAN_STATE }, 478 { 4 , "stat" ,"STAT" ,func_state ,PSSCAN_STATE },
466 { 4 , "rss" ,"RSS" ,func_rss ,PSSCAN_RSS }, 479 { 4 , "rss" ,"RSS" ,func_rss ,PSSCAN_RSS },
480#endif
467#if ENABLE_SELINUX 481#if ENABLE_SELINUX
468 { 35 , "label" ,"LABEL" ,func_label ,PSSCAN_CONTEXT }, 482 { 35 , "label" ,"LABEL" ,func_label ,PSSCAN_CONTEXT },
469#endif 483#endif
@@ -602,6 +616,8 @@ static void format_process(const procps_status_t *ps)
602#if ENABLE_SELINUX 616#if ENABLE_SELINUX
603# define SELINUX_O_PREFIX "label," 617# define SELINUX_O_PREFIX "label,"
604# define DEFAULT_O_STR (SELINUX_O_PREFIX "pid,user" IF_FEATURE_PS_TIME(",time") ",args") 618# define DEFAULT_O_STR (SELINUX_O_PREFIX "pid,user" IF_FEATURE_PS_TIME(",time") ",args")
619#elif ENABLE_PLATFORM_MINGW32
620# define DEFAULT_O_STR ("pid,comm")
605#else 621#else
606# define DEFAULT_O_STR ("pid,user" IF_FEATURE_PS_TIME(",time") ",args") 622# define DEFAULT_O_STR ("pid,user" IF_FEATURE_PS_TIME(",time") ",args")
607#endif 623#endif