diff options
author | Martin Baulig <martin@src.gnome.org> | 1998-10-26 09:53:08 +0000 |
---|---|---|
committer | Martin Baulig <martin@src.gnome.org> | 1998-10-26 09:53:08 +0000 |
commit | bdc4e08454cb6d175f4e6e36e5a63aa46dae09b5 (patch) | |
tree | 90a3ccd5434bb006bc36e608670626a4e5090355 /examples/first.c | |
parent | 65e3bf19ab663e7322a363e722da90573e37c744 (diff) | |
download | libgtop-bdc4e08454cb6d175f4e6e36e5a63aa46dae09b5.tar.gz |
Added new feature (proc_args) to get command line arguments:
typedef struct _glibtop_proc_args glibtop_proc_args;
struct _glibtop_proc_args
{
u_int64_t flags,
size; /* GLIBTOP_PROC_ARGS_SIZE */
};
Returns a string containing all command line arguments of the process,
the `unsigned' parameter is the maximum length of this string; if it
is zero then no limit will be set.
extern const char *glibtop_get_proc_args_l __P((glibtop *, glibtop_proc_args *, pid_t, unsigned));
Diffstat (limited to 'examples/first.c')
-rw-r--r-- | examples/first.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/examples/first.c b/examples/first.c index 547b78a0..87b69a6f 100644 --- a/examples/first.c +++ b/examples/first.c @@ -43,7 +43,7 @@ main (int argc, char *argv []) glibtop_union data; glibtop_sysdeps sysdeps; unsigned c, method, count, port, i, *ptr; - char buffer [BUFSIZ]; + char buffer [BUFSIZ], *args; pid_t pid, ppid; count = PROFILE_COUNT; @@ -324,6 +324,17 @@ main (int argc, char *argv []) printf ("\n"); + args = glibtop_get_proc_args (&data.proc_args, pid, 0); + + printf ("Proc_Args PID %5d (0x%08lx): %lu - '%s'\n", (int) pid, + (unsigned long) data.proc_args.flags, + (unsigned long) data.proc_args.size, + args); + + glibtop_free (args); + + printf ("\n"); + for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_state (&data.proc_state, ppid); @@ -418,6 +429,17 @@ main (int argc, char *argv []) printf ("\n"); + args = glibtop_get_proc_args (&data.proc_args, ppid, 0); + + printf ("Proc_Args PID %5d (0x%08lx): %lu - '%s'\n", (int) ppid, + (unsigned long) data.proc_args.flags, + (unsigned long) data.proc_args.size, + args); + + glibtop_free (args); + + printf ("\n"); + for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_state (&data.proc_state, 1); @@ -511,6 +533,17 @@ main (int argc, char *argv []) (unsigned long) data.proc_kernel.nwchan, data.proc_kernel.wchan); + printf ("\n"); + + args = glibtop_get_proc_args (&data.proc_args, 1, 0); + + printf ("Proc_Args PID %5d (0x%08lx): %lu - '%s'\n", 1, + (unsigned long) data.proc_args.flags, + (unsigned long) data.proc_args.size, + args); + + glibtop_free (args); + glibtop_close (); exit (0); |