summaryrefslogtreecommitdiff
path: root/libps/procstat.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1999-06-02 06:24:39 +0000
committerRoland McGrath <roland@gnu.org>1999-06-02 06:24:39 +0000
commit4a4796ab4f9d43989e2b89fe4f98a8c7f69e80d7 (patch)
tree89a3bae010fc5979b50d08701d085b853f1e8388 /libps/procstat.c
parent793c7dd6961f5caed444bb10a871e4d2aff8b0fc (diff)
1999-06-02 Roland McGrath <roland@baalperazim.frob.com>
* ps.h (PSTAT_ENV): New macro. (struct proc_stat): New members `env', `env_len', `env_vm_alloced'. (proc_stat_env, proc_stat_env_len): New accessor macros. (PSTAT_USER_BASE): Increase value to leave more room for additions. * procstat.c (proc_stat_set_flags): Handle environment. (_proc_stat_free): Likewise. * spec.c (ps_get_env, ps_env_getter): New function and constant. (specs): New spec "Env" using ps_env_getter and ps_emit_args.
Diffstat (limited to 'libps/procstat.c')
-rw-r--r--libps/procstat.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/libps/procstat.c b/libps/procstat.c
index b9a3e632..8b120bd8 100644
--- a/libps/procstat.c
+++ b/libps/procstat.c
@@ -1,6 +1,6 @@
/* The proc_stat type, which holds information about a hurd process.
- Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
Written by Miles Bader <miles@gnu.ai.mit.edu>
@@ -938,6 +938,26 @@ proc_stat_set_flags (struct proc_stat *ps, ps_flags_t flags)
}
}
+ /* The process's exec environment */
+ if (NEED (PSTAT_ENV, PSTAT_PID))
+ {
+ char *buf = malloc (100);
+ ps->env_len = 100;
+ ps->env = buf;
+ if (ps->env)
+ {
+ if (proc_getprocenv (server, ps->pid, &ps->env, &ps->env_len))
+ free (buf);
+ else
+ {
+ have |= PSTAT_ENV;
+ ps->env_vm_alloced = (ps->env != buf);
+ if (ps->env_vm_alloced)
+ free (buf);
+ }
+ }
+ }
+
/* The ctty id port; note that this is just a magic cookie;
we use it to fetch a port to the actual terminal -- it's not useful for
much else. */
@@ -1049,6 +1069,7 @@ _proc_stat_free (ps)
MFREEMEM (PSTAT_THREAD_BASIC, thread_basic_info, 0, 0, 0, 0);
MFREEMEM (PSTAT_THREAD_SCHED, thread_sched_info, 0, 0, 0, 0);
MFREEMEM (PSTAT_ARGS, args, ps->args_len, ps->args_vm_alloced, 0, char);
+ MFREEMEM (PSTAT_ENV, env, ps->env_len, ps->env_vm_alloced, 0, char);
MFREEMEM (PSTAT_TASK_EVENTS, task_events_info, ps->task_events_info_size,
0, &ps->task_events_info_buf, char);