aboutsummaryrefslogtreecommitdiff
path: root/procps/ps.c
diff options
context:
space:
mode:
Diffstat (limited to 'procps/ps.c')
-rw-r--r--procps/ps.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/procps/ps.c b/procps/ps.c
index 815c11578..a4de11379 100644
--- a/procps/ps.c
+++ b/procps/ps.c
@@ -35,7 +35,6 @@
35//config: bool "Enable -o time and -o etime specifiers" 35//config: bool "Enable -o time and -o etime specifiers"
36//config: default y 36//config: default y
37//config: depends on (PS || MINIPS) && DESKTOP 37//config: depends on (PS || MINIPS) && DESKTOP
38//config: select PLATFORM_LINUX
39//config: 38//config:
40//config:config FEATURE_PS_UNUSUAL_SYSTEMS 39//config:config FEATURE_PS_UNUSUAL_SYSTEMS
41//config: bool "Support Linux prior to 2.4.0 and non-ELF systems" 40//config: bool "Support Linux prior to 2.4.0 and non-ELF systems"
@@ -126,6 +125,8 @@ static unsigned long get_uptime(void)
126 if (sysinfo(&info) < 0) 125 if (sysinfo(&info) < 0)
127 return 0; 126 return 0;
128 return info.uptime; 127 return info.uptime;
128#elif ENABLE_PLATFORM_MINGW32
129 return GetTickCount64()/1000;
129#elif 1 130#elif 1
130 unsigned long uptime; 131 unsigned long uptime;
131 char buf[sizeof(uptime)*3 + 2]; 132 char buf[sizeof(uptime)*3 + 2];
@@ -238,10 +239,12 @@ static void func_comm(char *buf, int size, const procps_status_t *ps)
238 safe_strncpy(buf, ps->comm, size+1); 239 safe_strncpy(buf, ps->comm, size+1);
239} 240}
240 241
242#if !ENABLE_PLATFORM_MINGW32
241static void func_state(char *buf, int size, const procps_status_t *ps) 243static void func_state(char *buf, int size, const procps_status_t *ps)
242{ 244{
243 safe_strncpy(buf, ps->state, size+1); 245 safe_strncpy(buf, ps->state, size+1);
244} 246}
247#endif
245 248
246static void func_args(char *buf, int size, const procps_status_t *ps) 249static void func_args(char *buf, int size, const procps_status_t *ps)
247{ 250{
@@ -258,6 +261,7 @@ static void func_ppid(char *buf, int size, const procps_status_t *ps)
258 sprintf(buf, "%*u", size, ps->ppid); 261 sprintf(buf, "%*u", size, ps->ppid);
259} 262}
260 263
264#if !ENABLE_PLATFORM_MINGW32
261static void func_pgid(char *buf, int size, const procps_status_t *ps) 265static void func_pgid(char *buf, int size, const procps_status_t *ps)
262{ 266{
263 sprintf(buf, "%*u", size, ps->pgid); 267 sprintf(buf, "%*u", size, ps->pgid);
@@ -294,6 +298,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" */ 298 if (ps->tty_major) /* tty field of "0" means "no tty" */
295 snprintf(buf, size+1, "%u,%u", ps->tty_major, ps->tty_minor); 299 snprintf(buf, size+1, "%u,%u", ps->tty_major, ps->tty_minor);
296} 300}
301#endif
297 302
298#if ENABLE_FEATURE_PS_ADDITIONAL_COLUMNS 303#if ENABLE_FEATURE_PS_ADDITIONAL_COLUMNS
299static void func_rgroup(char *buf, int size, const procps_status_t *ps) 304static void func_rgroup(char *buf, int size, const procps_status_t *ps)
@@ -384,7 +389,9 @@ static const ps_out_t out_spec[] = {
384 { MAX_WIDTH , "args" ,"COMMAND",func_args ,PSSCAN_COMM }, 389 { MAX_WIDTH , "args" ,"COMMAND",func_args ,PSSCAN_COMM },
385 { 5 , "pid" ,"PID" ,func_pid ,PSSCAN_PID }, 390 { 5 , "pid" ,"PID" ,func_pid ,PSSCAN_PID },
386 { 5 , "ppid" ,"PPID" ,func_ppid ,PSSCAN_PPID }, 391 { 5 , "ppid" ,"PPID" ,func_ppid ,PSSCAN_PPID },
392#if !ENABLE_PLATFORM_MINGW32
387 { 5 , "pgid" ,"PGID" ,func_pgid ,PSSCAN_PGID }, 393 { 5 , "pgid" ,"PGID" ,func_pgid ,PSSCAN_PGID },
394#endif
388#if ENABLE_FEATURE_PS_TIME 395#if ENABLE_FEATURE_PS_TIME
389 { sizeof("ELAPSED")-1, "etime" ,"ELAPSED",func_etime ,PSSCAN_START_TIME }, 396 { sizeof("ELAPSED")-1, "etime" ,"ELAPSED",func_etime ,PSSCAN_START_TIME },
390#endif 397#endif
@@ -397,12 +404,14 @@ static const ps_out_t out_spec[] = {
397#if ENABLE_FEATURE_PS_TIME 404#if ENABLE_FEATURE_PS_TIME
398 { 5 , "time" ,"TIME" ,func_time ,PSSCAN_STIME | PSSCAN_UTIME }, 405 { 5 , "time" ,"TIME" ,func_time ,PSSCAN_STIME | PSSCAN_UTIME },
399#endif 406#endif
407#if !ENABLE_PLATFORM_MINGW32
400 { 6 , "tty" ,"TT" ,func_tty ,PSSCAN_TTY }, 408 { 6 , "tty" ,"TT" ,func_tty ,PSSCAN_TTY },
401 { 4 , "vsz" ,"VSZ" ,func_vsz ,PSSCAN_VSZ }, 409 { 4 , "vsz" ,"VSZ" ,func_vsz ,PSSCAN_VSZ },
402/* Not mandated, but useful: */ 410/* Not mandated, but useful: */
403 { 5 , "sid" ,"SID" ,func_sid ,PSSCAN_SID }, 411 { 5 , "sid" ,"SID" ,func_sid ,PSSCAN_SID },
404 { 4 , "stat" ,"STAT" ,func_state ,PSSCAN_STATE }, 412 { 4 , "stat" ,"STAT" ,func_state ,PSSCAN_STATE },
405 { 4 , "rss" ,"RSS" ,func_rss ,PSSCAN_RSS }, 413 { 4 , "rss" ,"RSS" ,func_rss ,PSSCAN_RSS },
414#endif
406#if ENABLE_SELINUX 415#if ENABLE_SELINUX
407 { 35 , "label" ,"LABEL" ,func_label ,PSSCAN_CONTEXT }, 416 { 35 , "label" ,"LABEL" ,func_label ,PSSCAN_CONTEXT },
408#endif 417#endif
@@ -541,6 +550,8 @@ static void format_process(const procps_status_t *ps)
541#if ENABLE_SELINUX 550#if ENABLE_SELINUX
542# define SELINUX_O_PREFIX "label," 551# define SELINUX_O_PREFIX "label,"
543# define DEFAULT_O_STR (SELINUX_O_PREFIX "pid,user" IF_FEATURE_PS_TIME(",time") ",args") 552# define DEFAULT_O_STR (SELINUX_O_PREFIX "pid,user" IF_FEATURE_PS_TIME(",time") ",args")
553#elif ENABLE_PLATFORM_MINGW32
554# define DEFAULT_O_STR ("pid,ppid,user" IF_FEATURE_PS_TIME(",time,etime") ",args")
544#else 555#else
545# define DEFAULT_O_STR ("pid,user" IF_FEATURE_PS_TIME(",time") ",args") 556# define DEFAULT_O_STR ("pid,user" IF_FEATURE_PS_TIME(",time") ",args")
546#endif 557#endif