Add a /proc/<pid>/environ proc file handler, analogous to /proc/<pid>/cmdline.

This commit is contained in:
Erik M. Bray 2017-01-10 16:03:10 +01:00 committed by Corinna Vinschen
parent 578bbc3a29
commit 5bebfa17c5
1 changed files with 22 additions and 0 deletions

View File

@ -49,6 +49,7 @@ static off_t format_process_ctty (void *, char *&);
static off_t format_process_fd (void *, char *&);
static off_t format_process_mounts (void *, char *&);
static off_t format_process_mountinfo (void *, char *&);
static off_t format_process_environ (void *, char *&);
static const virt_tab_t process_tab[] =
{
@ -57,6 +58,7 @@ static const virt_tab_t process_tab[] =
{ _VN ("cmdline"), FH_PROCESS, virt_file, format_process_cmdline },
{ _VN ("ctty"), FH_PROCESS, virt_file, format_process_ctty },
{ _VN ("cwd"), FH_PROCESS, virt_symlink, format_process_cwd },
{ _VN ("environ"), FH_PROCESS, virt_file, format_process_environ },
{ _VN ("exe"), FH_PROCESS, virt_symlink, format_process_exename },
{ _VN ("exename"), FH_PROCESS, virt_file, format_process_exename },
{ _VN ("fd"), FH_PROCESSFD, virt_directory, format_process_fd },
@ -570,6 +572,26 @@ format_process_winexename (void *data, char *&destbuf)
return len;
}
static off_t
format_process_environ (void *data, char *&destbuf)
{
_pinfo *p = (_pinfo *) data;
size_t fs;
if (destbuf)
{
cfree (destbuf);
destbuf = NULL;
}
destbuf = p->environ (fs);
if (!destbuf || !*destbuf)
{
destbuf = cstrdup ("<defunct>");
fs = strlen (destbuf) + 1;
}
return fs;
}
struct heap_info
{
struct heap