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 + + * proclist.c: (print_pids), (main): + + Improved example. + 2005-12-12 Benoît Dejean * .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 -int main() +#include +#include + + +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();