Improved example.

* proclist.c: (print_pids), (main):

	Improved example.
This commit is contained in:
Benoît Dejean
2005-12-15 13:05:55 +00:00
parent 3afe2bf629
commit 101fe5874f
2 changed files with 24 additions and 3 deletions

View File

@@ -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> 2005-12-12 Benoît Dejean <benoit@placenet.org>
* .cvsignore: * .cvsignore:

View File

@@ -5,22 +5,37 @@
#include <stdio.h> #include <stdio.h>
int main() #include <unistd.h>
#include <sys/types.h>
static void print_pids(guint64 which, guint64 arg)
{ {
unsigned *pids; unsigned *pids;
unsigned i; unsigned i;
glibtop_proclist buf; 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) for (i = 0; i < buf.number; ++i)
printf("%u ", pids[i]); printf("%u ", pids[i]);
putchar('\n'); putchar('\n');
putchar('\n');
g_free(pids); g_free(pids);
}
int main()
{
glibtop_init();
print_pids(GLIBTOP_KERN_PROC_ALL, 0);
print_pids(GLIBTOP_KERN_PROC_UID, getuid());
glibtop_close(); glibtop_close();