summaryrefslogtreecommitdiff
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 c65fa012a..9fca3524e 100644
--- a/procps/ps.c
+++ b/procps/ps.c
@@ -240,6 +240,7 @@ static unsigned get_kernel_HZ(void)
240 240
241/* Print value to buf, max size+1 chars (including trailing '\0') */ 241/* Print value to buf, max size+1 chars (including trailing '\0') */
242 242
243#if !ENABLE_PLATFORM_MINGW32
243static void func_user(char *buf, int size, const procps_status_t *ps) 244static void func_user(char *buf, int size, const procps_status_t *ps)
244{ 245{
245#if 1 246#if 1
@@ -263,12 +264,14 @@ static void func_group(char *buf, int size, const procps_status_t *ps)
263{ 264{
264 safe_strncpy(buf, get_cached_groupname(ps->gid), size+1); 265 safe_strncpy(buf, get_cached_groupname(ps->gid), size+1);
265} 266}
267#endif
266 268
267static void func_comm(char *buf, int size, const procps_status_t *ps) 269static void func_comm(char *buf, int size, const procps_status_t *ps)
268{ 270{
269 safe_strncpy(buf, ps->comm, size+1); 271 safe_strncpy(buf, ps->comm, size+1);
270} 272}
271 273
274#if !ENABLE_PLATFORM_MINGW32
272static void func_state(char *buf, int size, const procps_status_t *ps) 275static void func_state(char *buf, int size, const procps_status_t *ps)
273{ 276{
274 safe_strncpy(buf, ps->state, size+1); 277 safe_strncpy(buf, ps->state, size+1);
@@ -278,12 +281,14 @@ static void func_args(char *buf, int size, const procps_status_t *ps)
278{ 281{
279 read_cmdline(buf, size+1, ps->pid, ps->comm); 282 read_cmdline(buf, size+1, ps->pid, ps->comm);
280} 283}
284#endif
281 285
282static void func_pid(char *buf, int size, const procps_status_t *ps) 286static void func_pid(char *buf, int size, const procps_status_t *ps)
283{ 287{
284 sprintf(buf, "%*u", size, ps->pid); 288 sprintf(buf, "%*u", size, ps->pid);
285} 289}
286 290
291#if !ENABLE_PLATFORM_MINGW32
287static void func_ppid(char *buf, int size, const procps_status_t *ps) 292static void func_ppid(char *buf, int size, const procps_status_t *ps)
288{ 293{
289 sprintf(buf, "%*u", size, ps->ppid); 294 sprintf(buf, "%*u", size, ps->ppid);
@@ -320,6 +325,7 @@ static void func_tty(char *buf, int size, const procps_status_t *ps)
320 if (ps->tty_major) /* tty field of "0" means "no tty" */ 325 if (ps->tty_major) /* tty field of "0" means "no tty" */
321 snprintf(buf, size+1, "%u,%u", ps->tty_major, ps->tty_minor); 326 snprintf(buf, size+1, "%u,%u", ps->tty_major, ps->tty_minor);
322} 327}
328#endif
323 329
324#if ENABLE_FEATURE_PS_ADDITIONAL_COLUMNS 330#if ENABLE_FEATURE_PS_ADDITIONAL_COLUMNS
325 331
@@ -390,13 +396,19 @@ static void func_pcpu(char *buf, int size, const procps_status_t *ps)
390 396
391static const ps_out_t out_spec[] = { 397static const ps_out_t out_spec[] = {
392/* Mandated by http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ps.html: */ 398/* Mandated by http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ps.html: */
399#if !ENABLE_PLATFORM_MINGW32
393 { 8 , "user" ,"USER" ,func_user ,PSSCAN_UIDGID }, 400 { 8 , "user" ,"USER" ,func_user ,PSSCAN_UIDGID },
394 { 8 , "group" ,"GROUP" ,func_group ,PSSCAN_UIDGID }, 401 { 8 , "group" ,"GROUP" ,func_group ,PSSCAN_UIDGID },
402#endif
395 { 16 , "comm" ,"COMMAND",func_comm ,PSSCAN_COMM }, 403 { 16 , "comm" ,"COMMAND",func_comm ,PSSCAN_COMM },
404#if !ENABLE_PLATFORM_MINGW32
396 { MAX_WIDTH , "args" ,"COMMAND",func_args ,PSSCAN_COMM }, 405 { MAX_WIDTH , "args" ,"COMMAND",func_args ,PSSCAN_COMM },
406#endif
397 { 5 , "pid" ,"PID" ,func_pid ,PSSCAN_PID }, 407 { 5 , "pid" ,"PID" ,func_pid ,PSSCAN_PID },
408#if !ENABLE_PLATFORM_MINGW32
398 { 5 , "ppid" ,"PPID" ,func_ppid ,PSSCAN_PPID }, 409 { 5 , "ppid" ,"PPID" ,func_ppid ,PSSCAN_PPID },
399 { 5 , "pgid" ,"PGID" ,func_pgid ,PSSCAN_PGID }, 410 { 5 , "pgid" ,"PGID" ,func_pgid ,PSSCAN_PGID },
411#endif
400#if ENABLE_FEATURE_PS_TIME 412#if ENABLE_FEATURE_PS_TIME
401 { sizeof("ELAPSED")-1, "etime" ,"ELAPSED",func_etime ,PSSCAN_START_TIME }, 413 { sizeof("ELAPSED")-1, "etime" ,"ELAPSED",func_etime ,PSSCAN_START_TIME },
402#endif 414#endif
@@ -409,11 +421,13 @@ static const ps_out_t out_spec[] = {
409#if ENABLE_FEATURE_PS_TIME 421#if ENABLE_FEATURE_PS_TIME
410 { 6 , "time" ,"TIME" ,func_time ,PSSCAN_STIME | PSSCAN_UTIME }, 422 { 6 , "time" ,"TIME" ,func_time ,PSSCAN_STIME | PSSCAN_UTIME },
411#endif 423#endif
424#if !ENABLE_PLATFORM_MINGW32
412 { 6 , "tty" ,"TT" ,func_tty ,PSSCAN_TTY }, 425 { 6 , "tty" ,"TT" ,func_tty ,PSSCAN_TTY },
413 { 4 , "vsz" ,"VSZ" ,func_vsz ,PSSCAN_VSZ }, 426 { 4 , "vsz" ,"VSZ" ,func_vsz ,PSSCAN_VSZ },
414/* Not mandated, but useful: */ 427/* Not mandated, but useful: */
415 { 4 , "stat" ,"STAT" ,func_state ,PSSCAN_STATE }, 428 { 4 , "stat" ,"STAT" ,func_state ,PSSCAN_STATE },
416 { 4 , "rss" ,"RSS" ,func_rss ,PSSCAN_RSS }, 429 { 4 , "rss" ,"RSS" ,func_rss ,PSSCAN_RSS },
430#endif
417#if ENABLE_SELINUX 431#if ENABLE_SELINUX
418 { 35 , "label" ,"LABEL" ,func_label ,PSSCAN_CONTEXT }, 432 { 35 , "label" ,"LABEL" ,func_label ,PSSCAN_CONTEXT },
419#endif 433#endif
@@ -552,6 +566,8 @@ static void format_process(const procps_status_t *ps)
552#if ENABLE_SELINUX 566#if ENABLE_SELINUX
553# define SELINUX_O_PREFIX "label," 567# define SELINUX_O_PREFIX "label,"
554# define DEFAULT_O_STR (SELINUX_O_PREFIX "pid,user" IF_FEATURE_PS_TIME(",time") ",args") 568# define DEFAULT_O_STR (SELINUX_O_PREFIX "pid,user" IF_FEATURE_PS_TIME(",time") ",args")
569#elif ENABLE_PLATFORM_MINGW32
570# define DEFAULT_O_STR ("pid,comm")
555#else 571#else
556# define DEFAULT_O_STR ("pid,user" IF_FEATURE_PS_TIME(",time") ",args") 572# define DEFAULT_O_STR ("pid,user" IF_FEATURE_PS_TIME(",time") ",args")
557#endif 573#endif