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));
This commit is contained in:
Martin Baulig
1998-10-26 09:53:08 +00:00
parent 65e3bf19ab
commit bdc4e08454
35 changed files with 575 additions and 26 deletions

View File

@@ -29,6 +29,7 @@ handle_parent_connection (int s)
glibtop_command _cmnd, *cmnd = &_cmnd;
glibtop_mountentry *mount_list;
char parameter [BUFSIZ];
unsigned short device;
int64_t *param_ptr;
int all_fs;
pid_t pid;
@@ -193,7 +194,7 @@ handle_parent_connection (int s)
do_output (s, resp, _offset_data (proc_segment), 0, NULL);
break;
case GLIBTOP_CMND_MOUNTLIST:
memcpy (&all_fs, parameter, sizeof (all_fs));
memcpy (&all_fs, parameter, sizeof (all_fs));
mount_list = glibtop_get_mountlist_l
(server, &resp->u.data.mountlist, all_fs);
do_output (s, resp, _offset_data (mountlist),
@@ -206,6 +207,12 @@ handle_parent_connection (int s)
do_output (s, resp, _offset_data (fsusage),
0, NULL);
break;
case GLIBTOP_CMND_PPP:
memcpy (&device, parameter, sizeof (device));
glibtop_get_ppp_l
(server, &resp->u.data.ppp, device);
do_output (s, resp, _offset_data (ppp), 0, NULL);
break;
default:
glibtop_warn ("Parent received unknown command %u",
cmnd->command);

View File

@@ -45,6 +45,7 @@ GLIBTOP_SUID_PROC_TIME +
GLIBTOP_SUID_PROC_SIGNAL +
GLIBTOP_SUID_PROC_KERNEL +
GLIBTOP_SUID_PROC_SEGMENT +
GLIBTOP_SUID_PROC_ARGS +
GLIBTOP_SUID_PROC_MAP +
GLIBTOP_SUID_PPP;

View File

@@ -27,6 +27,8 @@ handle_slave_connection (int input, int output)
glibtop *server = glibtop_global_server;
int64_t *param_ptr;
void *ptr;
unsigned short max_len;
pid_t pid;
glibtop_response _resp, *resp = &_resp;
@@ -77,6 +79,19 @@ handle_slave_connection (int input, int output)
glibtop_free_r (server, ptr);
break;
#endif
#if GLIBTOP_SUID_PROC_ARGS
case GLIBTOP_CMND_PROC_ARGS:
memcpy (&pid, parameter, sizeof (pid_t));
memcpy (&max_len, parameter + sizeof (pid_t),
sizeof (max_len));
ptr = glibtop_get_proc_args_p (server,
&resp->u.data.proc_args,
pid, max_len);
do_output (output, resp, _offset_data (proc_args),
resp->u.data.proc_args.size, ptr);
glibtop_free_r (server, ptr);
break;
#endif
#if GLIBTOP_SUID_PROC_MAP
case GLIBTOP_CMND_PROC_MAP:
memcpy (&pid, parameter, sizeof (pid_t));
@@ -101,7 +116,7 @@ handle_slave_command (glibtop_command *cmnd, glibtop_response *resp,
const void *parameter)
{
glibtop *server = glibtop_global_server;
unsigned short device;
unsigned device;
pid_t pid;
switch (cmnd->command) {