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, 16 insertions, 0 deletions
diff --git a/procps/ps.c b/procps/ps.c
index eb1946d27..3e83a3e03 100644
--- a/procps/ps.c
+++ b/procps/ps.c
@@ -286,6 +286,7 @@ static unsigned get_kernel_HZ(void)
286 286
287/* Print value to buf, max size+1 chars (including trailing '\0') */ 287/* Print value to buf, max size+1 chars (including trailing '\0') */
288 288
289#if !ENABLE_PLATFORM_MINGW32
289static void func_user(char *buf, int size, const procps_status_t *ps) 290static void func_user(char *buf, int size, const procps_status_t *ps)
290{ 291{
291#if 1 292#if 1
@@ -309,12 +310,14 @@ static void func_group(char *buf, int size, const procps_status_t *ps)
309{ 310{
310 safe_strncpy(buf, get_cached_groupname(ps->gid), size+1); 311 safe_strncpy(buf, get_cached_groupname(ps->gid), size+1);
311} 312}
313#endif
312 314
313static void func_comm(char *buf, int size, const procps_status_t *ps) 315static void func_comm(char *buf, int size, const procps_status_t *ps)
314{ 316{
315 safe_strncpy(buf, ps->comm, size+1); 317 safe_strncpy(buf, ps->comm, size+1);
316} 318}
317 319
320#if !ENABLE_PLATFORM_MINGW32
318static void func_state(char *buf, int size, const procps_status_t *ps) 321static void func_state(char *buf, int size, const procps_status_t *ps)
319{ 322{
320 safe_strncpy(buf, ps->state, size+1); 323 safe_strncpy(buf, ps->state, size+1);
@@ -324,12 +327,14 @@ static void func_args(char *buf, int size, const procps_status_t *ps)
324{ 327{
325 read_cmdline(buf, size+1, ps->pid, ps->comm); 328 read_cmdline(buf, size+1, ps->pid, ps->comm);
326} 329}
330#endif
327 331
328static void func_pid(char *buf, int size, const procps_status_t *ps) 332static void func_pid(char *buf, int size, const procps_status_t *ps)
329{ 333{
330 sprintf(buf, "%*u", size, ps->pid); 334 sprintf(buf, "%*u", size, ps->pid);
331} 335}
332 336
337#if !ENABLE_PLATFORM_MINGW32
333static void func_ppid(char *buf, int size, const procps_status_t *ps) 338static void func_ppid(char *buf, int size, const procps_status_t *ps)
334{ 339{
335 sprintf(buf, "%*u", size, ps->ppid); 340 sprintf(buf, "%*u", size, ps->ppid);
@@ -371,6 +376,7 @@ static void func_tty(char *buf, int size, const procps_status_t *ps)
371 if (ps->tty_major) /* tty field of "0" means "no tty" */ 376 if (ps->tty_major) /* tty field of "0" means "no tty" */
372 snprintf(buf, size+1, "%u,%u", ps->tty_major, ps->tty_minor); 377 snprintf(buf, size+1, "%u,%u", ps->tty_major, ps->tty_minor);
373} 378}
379#endif
374 380
375#if ENABLE_FEATURE_PS_ADDITIONAL_COLUMNS 381#if ENABLE_FEATURE_PS_ADDITIONAL_COLUMNS
376 382
@@ -436,13 +442,19 @@ static void func_pcpu(char *buf, int size, const procps_status_t *ps)
436 442
437static const ps_out_t out_spec[] = { 443static const ps_out_t out_spec[] = {
438/* Mandated by http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ps.html: */ 444/* Mandated by http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ps.html: */
445#if !ENABLE_PLATFORM_MINGW32
439 { 8 , "user" ,"USER" ,func_user ,PSSCAN_UIDGID }, 446 { 8 , "user" ,"USER" ,func_user ,PSSCAN_UIDGID },
440 { 8 , "group" ,"GROUP" ,func_group ,PSSCAN_UIDGID }, 447 { 8 , "group" ,"GROUP" ,func_group ,PSSCAN_UIDGID },
448#endif
441 { 16 , "comm" ,"COMMAND",func_comm ,PSSCAN_COMM }, 449 { 16 , "comm" ,"COMMAND",func_comm ,PSSCAN_COMM },
450#if !ENABLE_PLATFORM_MINGW32
442 { MAX_WIDTH , "args" ,"COMMAND",func_args ,PSSCAN_COMM }, 451 { MAX_WIDTH , "args" ,"COMMAND",func_args ,PSSCAN_COMM },
452#endif
443 { 5 , "pid" ,"PID" ,func_pid ,PSSCAN_PID }, 453 { 5 , "pid" ,"PID" ,func_pid ,PSSCAN_PID },
454#if !ENABLE_PLATFORM_MINGW32
444 { 5 , "ppid" ,"PPID" ,func_ppid ,PSSCAN_PPID }, 455 { 5 , "ppid" ,"PPID" ,func_ppid ,PSSCAN_PPID },
445 { 5 , "pgid" ,"PGID" ,func_pgid ,PSSCAN_PGID }, 456 { 5 , "pgid" ,"PGID" ,func_pgid ,PSSCAN_PGID },
457#endif
446#if ENABLE_FEATURE_PS_TIME 458#if ENABLE_FEATURE_PS_TIME
447 { sizeof("ELAPSED")-1, "etime" ,"ELAPSED",func_etime ,PSSCAN_START_TIME }, 459 { sizeof("ELAPSED")-1, "etime" ,"ELAPSED",func_etime ,PSSCAN_START_TIME },
448#endif 460#endif
@@ -455,12 +467,14 @@ static const ps_out_t out_spec[] = {
455#if ENABLE_FEATURE_PS_TIME 467#if ENABLE_FEATURE_PS_TIME
456 { 6 , "time" ,"TIME" ,func_time ,PSSCAN_STIME | PSSCAN_UTIME }, 468 { 6 , "time" ,"TIME" ,func_time ,PSSCAN_STIME | PSSCAN_UTIME },
457#endif 469#endif
470#if !ENABLE_PLATFORM_MINGW32
458 { 6 , "tty" ,"TT" ,func_tty ,PSSCAN_TTY }, 471 { 6 , "tty" ,"TT" ,func_tty ,PSSCAN_TTY },
459 { 4 , "vsz" ,"VSZ" ,func_vsz ,PSSCAN_VSZ }, 472 { 4 , "vsz" ,"VSZ" ,func_vsz ,PSSCAN_VSZ },
460/* Not mandated, but useful: */ 473/* Not mandated, but useful: */
461 { 5 , "sid" ,"SID" ,func_sid ,PSSCAN_SID }, 474 { 5 , "sid" ,"SID" ,func_sid ,PSSCAN_SID },
462 { 4 , "stat" ,"STAT" ,func_state ,PSSCAN_STATE }, 475 { 4 , "stat" ,"STAT" ,func_state ,PSSCAN_STATE },
463 { 4 , "rss" ,"RSS" ,func_rss ,PSSCAN_RSS }, 476 { 4 , "rss" ,"RSS" ,func_rss ,PSSCAN_RSS },
477#endif
464#if ENABLE_SELINUX 478#if ENABLE_SELINUX
465 { 35 , "label" ,"LABEL" ,func_label ,PSSCAN_CONTEXT }, 479 { 35 , "label" ,"LABEL" ,func_label ,PSSCAN_CONTEXT },
466#endif 480#endif
@@ -599,6 +613,8 @@ static void format_process(const procps_status_t *ps)
599#if ENABLE_SELINUX 613#if ENABLE_SELINUX
600# define SELINUX_O_PREFIX "label," 614# define SELINUX_O_PREFIX "label,"
601# define DEFAULT_O_STR (SELINUX_O_PREFIX "pid,user" IF_FEATURE_PS_TIME(",time") ",args") 615# define DEFAULT_O_STR (SELINUX_O_PREFIX "pid,user" IF_FEATURE_PS_TIME(",time") ",args")
616#elif ENABLE_PLATFORM_MINGW32
617# define DEFAULT_O_STR ("pid,comm")
602#else 618#else
603# define DEFAULT_O_STR ("pid,user" IF_FEATURE_PS_TIME(",time") ",args") 619# define DEFAULT_O_STR ("pid,user" IF_FEATURE_PS_TIME(",time") ",args")
604#endif 620#endif