diff options
author | Angelo Marletta <angelo.marletta@gmail.com> | 2012-06-15 03:18:03 +0100 |
---|---|---|
committer | Angelo Marletta <angelo.marletta@gmail.com> | 2012-06-15 03:18:03 +0100 |
commit | 5544c90d488caf7d19ee3d6c828cf0490e60a3a5 (patch) | |
tree | 81cf2fadbd31cf5fac385eb14d00d88697e48d5f /tests | |
parent | b774ed89bfeaf96905aaa85946771082302fc848 (diff) | |
download | cpulimit-5544c90d488caf7d19ee3d6c828cf0490e60a3a5.tar.gz |
added filter to process_iterator. process_group and everything else broken
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile | 2 | ||||
-rwxr-xr-x | tests/process_iterator_test | bin | 0 -> 24672 bytes | |||
-rw-r--r-- | tests/process_iterator_test.c | 12 |
3 files changed, 9 insertions, 5 deletions
diff --git a/tests/Makefile b/tests/Makefile index 7f1c8b4..11359e6 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,5 +1,5 @@ CC?=gcc -CFLAGS?=-Wall -O2 +CFLAGS?=-Wall -g TARGETS=busy process_iterator_test LIBS?=-lpthread diff --git a/tests/process_iterator_test b/tests/process_iterator_test Binary files differnew file mode 100755 index 0000000..f0204fd --- /dev/null +++ b/tests/process_iterator_test diff --git a/tests/process_iterator_test.c b/tests/process_iterator_test.c index 080195a..b8aec52 100644 --- a/tests/process_iterator_test.c +++ b/tests/process_iterator_test.c @@ -5,13 +5,17 @@ int main() { struct process_iterator it; struct process process; - init_process_iterator(&it); - while (read_next_process(&it, &process) != -1) + struct process_filter filter; + filter.pid = 2981; + filter.include_children = 1; + init_process_iterator(&it, &filter); + while (read_next_process(&it, &process) == 0) { printf("Read process %d\n", process.pid); printf("Parent %d\n", process.ppid); -// printf("Starttime %d\n", process.starttime); - printf("Jiffies %d\n", process.last_jiffies); + printf("Starttime %d\n", process.starttime); + printf("CPU time %d\n", process.cputime); + printf("\n"); } close_process_iterator(&it); return 0; |