aboutsummaryrefslogtreecommitdiff
path: root/procps
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2017-09-01 17:50:39 +0100
committerRon Yorston <rmy@pobox.com>2017-09-01 18:00:01 +0100
commitdd9f552bb1fee66f3155bbbb81c677def861ada0 (patch)
tree21c7f1f333a2a58361c813311188b286ea803c9c /procps
parentec3ecac715b299766c101be92caf8b7cffb2a8b5 (diff)
downloadbusybox-w32-dd9f552bb1fee66f3155bbbb81c677def861ada0.tar.gz
busybox-w32-dd9f552bb1fee66f3155bbbb81c677def861ada0.tar.bz2
busybox-w32-dd9f552bb1fee66f3155bbbb81c677def861ada0.zip
ps: add support for CPU and elapsed time columns
It may be necessary to run ps as administrator to get information about processes belonging to other users. The code to detect GetTickCount64 at run-time was imported from Git for Windows.
Diffstat (limited to 'procps')
-rw-r--r--procps/ps.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/procps/ps.c b/procps/ps.c
index a8541e6cf..de062fe8b 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,7 +125,7 @@ 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;
129#elif 1 128#elif !ENABLE_PLATFORM_MINGW32
130 unsigned long uptime; 129 unsigned long uptime;
131 char buf[sizeof(uptime)*3 + 2]; 130 char buf[sizeof(uptime)*3 + 2];
132 /* /proc/uptime is "UPTIME_SEC.NN IDLE_SEC.NN\n" 131 /* /proc/uptime is "UPTIME_SEC.NN IDLE_SEC.NN\n"
@@ -137,6 +136,8 @@ static unsigned long get_uptime(void)
137 buf[sizeof(buf)-1] = '\0'; 136 buf[sizeof(buf)-1] = '\0';
138 sscanf(buf, "%lu", &uptime); 137 sscanf(buf, "%lu", &uptime);
139 return uptime; 138 return uptime;
139#elif ENABLE_PLATFORM_MINGW32
140 return GetTickCount64()/1000;
140#else 141#else
141 struct timespec ts; 142 struct timespec ts;
142 if (clock_gettime(CLOCK_MONOTONIC, &ts) < 0) 143 if (clock_gettime(CLOCK_MONOTONIC, &ts) < 0)
@@ -556,7 +557,7 @@ static void format_process(const procps_status_t *ps)
556# define SELINUX_O_PREFIX "label," 557# define SELINUX_O_PREFIX "label,"
557# define DEFAULT_O_STR (SELINUX_O_PREFIX "pid,user" IF_FEATURE_PS_TIME(",time") ",args") 558# define DEFAULT_O_STR (SELINUX_O_PREFIX "pid,user" IF_FEATURE_PS_TIME(",time") ",args")
558#elif ENABLE_PLATFORM_MINGW32 559#elif ENABLE_PLATFORM_MINGW32
559# define DEFAULT_O_STR ("pid,ppid,comm") 560# define DEFAULT_O_STR ("pid,ppid" IF_FEATURE_PS_TIME(",time,etime") ",comm")
560#else 561#else
561# define DEFAULT_O_STR ("pid,user" IF_FEATURE_PS_TIME(",time") ",args") 562# define DEFAULT_O_STR ("pid,user" IF_FEATURE_PS_TIME(",time") ",args")
562#endif 563#endif