aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2018-03-28 13:23:53 +0100
committerRon Yorston <rmy@pobox.com>2018-03-28 13:23:53 +0100
commit49ef6618c2e101953032b2c660bf7b246d07ce2d (patch)
tree7f1bb4069f0968f56ca721871ac3965eb6b1b519
parent9348221cef7762c2f5814f50b18c6a79701f5cda (diff)
downloadbusybox-w32-49ef6618c2e101953032b2c660bf7b246d07ce2d.tar.gz
busybox-w32-49ef6618c2e101953032b2c660bf7b246d07ce2d.tar.bz2
busybox-w32-49ef6618c2e101953032b2c660bf7b246d07ce2d.zip
ps: clear status for each process
The original procps_scan function takes care to clear the status information before handling each process. Do the same for the WIN32 version. This requires moving the snapshot handle to the part of the structure that isn't cleared on each iteration.
-rw-r--r--include/libbb.h7
-rw-r--r--win32/process.c2
2 files changed, 6 insertions, 3 deletions
diff --git a/include/libbb.h b/include/libbb.h
index 2c0e02971..244d85e84 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -1840,7 +1840,11 @@ int FAST_FUNC procps_read_smaps(pid_t pid, struct smaprec *total,
1840 void (*cb)(struct smaprec *, void *), void *data); 1840 void (*cb)(struct smaprec *, void *), void *data);
1841 1841
1842typedef struct procps_status_t { 1842typedef struct procps_status_t {
1843#if !ENABLE_PLATFORM_MINGW32
1843 DIR *dir; 1844 DIR *dir;
1845#else
1846 HANDLE snapshot;
1847#endif
1844 IF_FEATURE_SHOW_THREADS(DIR *task_dir;) 1848 IF_FEATURE_SHOW_THREADS(DIR *task_dir;)
1845 uint8_t shift_pages_to_bytes; 1849 uint8_t shift_pages_to_bytes;
1846 uint8_t shift_pages_to_kb; 1850 uint8_t shift_pages_to_kb;
@@ -1879,9 +1883,6 @@ typedef struct procps_status_t {
1879#if ENABLE_FEATURE_TOP_SMP_PROCESS 1883#if ENABLE_FEATURE_TOP_SMP_PROCESS
1880 int last_seen_on_cpu; 1884 int last_seen_on_cpu;
1881#endif 1885#endif
1882#if ENABLE_PLATFORM_MINGW32
1883 HANDLE snapshot;
1884#endif
1885} procps_status_t; 1886} procps_status_t;
1886/* flag bits for procps_scan(xx, flags) calls */ 1887/* flag bits for procps_scan(xx, flags) calls */
1887enum { 1888enum {
diff --git a/win32/process.c b/win32/process.c
index 84613cfdb..e835be63a 100644
--- a/win32/process.c
+++ b/win32/process.c
@@ -433,6 +433,8 @@ UNUSED_PARAM
433 } 433 }
434 } 434 }
435 435
436 memset(&sp->vsz, 0, sizeof(*sp) - offsetof(procps_status_t, vsz));
437
436#if ENABLE_FEATURE_PS_TIME || ENABLE_FEATURE_PS_LONG 438#if ENABLE_FEATURE_PS_TIME || ENABLE_FEATURE_PS_LONG
437 if (flags & (PSSCAN_STIME|PSSCAN_UTIME|PSSCAN_START_TIME)) { 439 if (flags & (PSSCAN_STIME|PSSCAN_UTIME|PSSCAN_START_TIME)) {
438 HANDLE proc; 440 HANDLE proc;