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 54e6c40fc..742d1715e 100644
--- a/procps/ps.c
+++ b/procps/ps.c
@@ -209,6 +209,7 @@ struct globals {
209 209
210/* Print value to buf, max size+1 chars (including trailing '\0') */ 210/* Print value to buf, max size+1 chars (including trailing '\0') */
211 211
212#if !ENABLE_PLATFORM_MINGW32
212static void func_user(char *buf, int size, const procps_status_t *ps) 213static void func_user(char *buf, int size, const procps_status_t *ps)
213{ 214{
214#if 1 215#if 1
@@ -232,12 +233,14 @@ static void func_group(char *buf, int size, const procps_status_t *ps)
232{ 233{
233 safe_strncpy(buf, get_cached_groupname(ps->gid), size+1); 234 safe_strncpy(buf, get_cached_groupname(ps->gid), size+1);
234} 235}
236#endif
235 237
236static void func_comm(char *buf, int size, const procps_status_t *ps) 238static void func_comm(char *buf, int size, const procps_status_t *ps)
237{ 239{
238 safe_strncpy(buf, ps->comm, size+1); 240 safe_strncpy(buf, ps->comm, size+1);
239} 241}
240 242
243#if !ENABLE_PLATFORM_MINGW32
241static void func_state(char *buf, int size, const procps_status_t *ps) 244static void func_state(char *buf, int size, const procps_status_t *ps)
242{ 245{
243 safe_strncpy(buf, ps->state, size+1); 246 safe_strncpy(buf, ps->state, size+1);
@@ -247,12 +250,14 @@ static void func_args(char *buf, int size, const procps_status_t *ps)
247{ 250{
248 read_cmdline(buf, size+1, ps->pid, ps->comm); 251 read_cmdline(buf, size+1, ps->pid, ps->comm);
249} 252}
253#endif
250 254
251static void func_pid(char *buf, int size, const procps_status_t *ps) 255static void func_pid(char *buf, int size, const procps_status_t *ps)
252{ 256{
253 sprintf(buf, "%*u", size, ps->pid); 257 sprintf(buf, "%*u", size, ps->pid);
254} 258}
255 259
260#if !ENABLE_PLATFORM_MINGW32
256static void func_ppid(char *buf, int size, const procps_status_t *ps) 261static void func_ppid(char *buf, int size, const procps_status_t *ps)
257{ 262{
258 sprintf(buf, "%*u", size, ps->ppid); 263 sprintf(buf, "%*u", size, ps->ppid);
@@ -294,6 +299,7 @@ static void func_tty(char *buf, int size, const procps_status_t *ps)
294 if (ps->tty_major) /* tty field of "0" means "no tty" */ 299 if (ps->tty_major) /* tty field of "0" means "no tty" */
295 snprintf(buf, size+1, "%u,%u", ps->tty_major, ps->tty_minor); 300 snprintf(buf, size+1, "%u,%u", ps->tty_major, ps->tty_minor);
296} 301}
302#endif
297 303
298#if ENABLE_FEATURE_PS_ADDITIONAL_COLUMNS 304#if ENABLE_FEATURE_PS_ADDITIONAL_COLUMNS
299static void func_rgroup(char *buf, int size, const procps_status_t *ps) 305static void func_rgroup(char *buf, int size, const procps_status_t *ps)
@@ -378,13 +384,19 @@ static void func_pcpu(char *buf, int size, const procps_status_t *ps)
378 384
379static const ps_out_t out_spec[] = { 385static const ps_out_t out_spec[] = {
380/* Mandated by http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ps.html: */ 386/* Mandated by http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ps.html: */
387#if !ENABLE_PLATFORM_MINGW32
381 { 8 , "user" ,"USER" ,func_user ,PSSCAN_UIDGID }, 388 { 8 , "user" ,"USER" ,func_user ,PSSCAN_UIDGID },
382 { 8 , "group" ,"GROUP" ,func_group ,PSSCAN_UIDGID }, 389 { 8 , "group" ,"GROUP" ,func_group ,PSSCAN_UIDGID },
390#endif
383 { 16 , "comm" ,"COMMAND",func_comm ,PSSCAN_COMM }, 391 { 16 , "comm" ,"COMMAND",func_comm ,PSSCAN_COMM },
392#if !ENABLE_PLATFORM_MINGW32
384 { MAX_WIDTH , "args" ,"COMMAND",func_args ,PSSCAN_COMM }, 393 { MAX_WIDTH , "args" ,"COMMAND",func_args ,PSSCAN_COMM },
394#endif
385 { 5 , "pid" ,"PID" ,func_pid ,PSSCAN_PID }, 395 { 5 , "pid" ,"PID" ,func_pid ,PSSCAN_PID },
396#if !ENABLE_PLATFORM_MINGW32
386 { 5 , "ppid" ,"PPID" ,func_ppid ,PSSCAN_PPID }, 397 { 5 , "ppid" ,"PPID" ,func_ppid ,PSSCAN_PPID },
387 { 5 , "pgid" ,"PGID" ,func_pgid ,PSSCAN_PGID }, 398 { 5 , "pgid" ,"PGID" ,func_pgid ,PSSCAN_PGID },
399#endif
388#if ENABLE_FEATURE_PS_TIME 400#if ENABLE_FEATURE_PS_TIME
389 { sizeof("ELAPSED")-1, "etime" ,"ELAPSED",func_etime ,PSSCAN_START_TIME }, 401 { sizeof("ELAPSED")-1, "etime" ,"ELAPSED",func_etime ,PSSCAN_START_TIME },
390#endif 402#endif
@@ -397,12 +409,14 @@ static const ps_out_t out_spec[] = {
397#if ENABLE_FEATURE_PS_TIME 409#if ENABLE_FEATURE_PS_TIME
398 { 5 , "time" ,"TIME" ,func_time ,PSSCAN_STIME | PSSCAN_UTIME }, 410 { 5 , "time" ,"TIME" ,func_time ,PSSCAN_STIME | PSSCAN_UTIME },
399#endif 411#endif
412#if !ENABLE_PLATFORM_MINGW32
400 { 6 , "tty" ,"TT" ,func_tty ,PSSCAN_TTY }, 413 { 6 , "tty" ,"TT" ,func_tty ,PSSCAN_TTY },
401 { 4 , "vsz" ,"VSZ" ,func_vsz ,PSSCAN_VSZ }, 414 { 4 , "vsz" ,"VSZ" ,func_vsz ,PSSCAN_VSZ },
402/* Not mandated, but useful: */ 415/* Not mandated, but useful: */
403 { 5 , "sid" ,"SID" ,func_sid ,PSSCAN_SID }, 416 { 5 , "sid" ,"SID" ,func_sid ,PSSCAN_SID },
404 { 4 , "stat" ,"STAT" ,func_state ,PSSCAN_STATE }, 417 { 4 , "stat" ,"STAT" ,func_state ,PSSCAN_STATE },
405 { 4 , "rss" ,"RSS" ,func_rss ,PSSCAN_RSS }, 418 { 4 , "rss" ,"RSS" ,func_rss ,PSSCAN_RSS },
419#endif
406#if ENABLE_SELINUX 420#if ENABLE_SELINUX
407 { 35 , "label" ,"LABEL" ,func_label ,PSSCAN_CONTEXT }, 421 { 35 , "label" ,"LABEL" ,func_label ,PSSCAN_CONTEXT },
408#endif 422#endif
@@ -541,6 +555,8 @@ static void format_process(const procps_status_t *ps)
541#if ENABLE_SELINUX 555#if ENABLE_SELINUX
542# define SELINUX_O_PREFIX "label," 556# define SELINUX_O_PREFIX "label,"
543# define DEFAULT_O_STR (SELINUX_O_PREFIX "pid,user" IF_FEATURE_PS_TIME(",time") ",args") 557# define DEFAULT_O_STR (SELINUX_O_PREFIX "pid,user" IF_FEATURE_PS_TIME(",time") ",args")
558#elif ENABLE_PLATFORM_MINGW32
559# define DEFAULT_O_STR ("pid,comm")
544#else 560#else
545# define DEFAULT_O_STR ("pid,user" IF_FEATURE_PS_TIME(",time") ",args") 561# define DEFAULT_O_STR ("pid,user" IF_FEATURE_PS_TIME(",time") ",args")
546#endif 562#endif