diff options
author | Benoît Dejean <bdejean@src.gnome.org> | 2005-12-15 13:05:55 +0000 |
---|---|---|
committer | Benoît Dejean <bdejean@src.gnome.org> | 2005-12-15 13:05:55 +0000 |
commit | 101fe5874f6660cfca1d2a19756a746fa70aec77 (patch) | |
tree | 4528894e8279551fe7af80e86d71bcb484efc222 | |
parent | 3afe2bf6297b8ddd87cc9d244dc666fb884a2202 (diff) | |
download | libgtop-101fe5874f6660cfca1d2a19756a746fa70aec77.tar.gz |
Improved example.
* proclist.c: (print_pids), (main):
Improved example.
-rw-r--r-- | examples/ChangeLog | 6 | ||||
-rw-r--r-- | examples/proclist.c | 21 |
2 files changed, 24 insertions, 3 deletions
diff --git a/examples/ChangeLog b/examples/ChangeLog index d1dcfc3b..d60a6a16 100644 --- a/examples/ChangeLog +++ b/examples/ChangeLog @@ -1,3 +1,9 @@ +2005-12-15 Benoît Dejean <benoit@placenet.org> + + * proclist.c: (print_pids), (main): + + Improved example. + 2005-12-12 Benoît Dejean <benoit@placenet.org> * .cvsignore: diff --git a/examples/proclist.c b/examples/proclist.c index 209a5f5f..542e8e98 100644 --- a/examples/proclist.c +++ b/examples/proclist.c @@ -5,22 +5,37 @@ #include <stdio.h> -int main() +#include <unistd.h> +#include <sys/types.h> + + +static void print_pids(guint64 which, guint64 arg) { unsigned *pids; unsigned i; glibtop_proclist buf; - glibtop_init(); + pids = glibtop_get_proclist(&buf, which, arg); - pids = glibtop_get_proclist(&buf, 0, 0); + printf("glibtop_get_proclist(%#llx, %llu) -> %lu processes\n", + which, arg, (unsigned long)buf.number); for (i = 0; i < buf.number; ++i) printf("%u ", pids[i]); putchar('\n'); + putchar('\n'); g_free(pids); +} + + +int main() +{ + glibtop_init(); + + print_pids(GLIBTOP_KERN_PROC_ALL, 0); + print_pids(GLIBTOP_KERN_PROC_UID, getuid()); glibtop_close(); |