From 4a4796ab4f9d43989e2b89fe4f98a8c7f69e80d7 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 2 Jun 1999 06:24:39 +0000 Subject: 1999-06-02 Roland McGrath * 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. --- libps/procstat.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'libps/procstat.c') 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 @@ -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); -- cgit v1.2.3