summaryrefslogtreecommitdiff
path: root/proc
diff options
context:
space:
mode:
Diffstat (limited to 'proc')
-rw-r--r--proc/info.c41
-rw-r--r--proc/mgt.c4
-rw-r--r--proc/proc.h1
3 files changed, 46 insertions, 0 deletions
diff --git a/proc/info.c b/proc/info.c
index 3c1bf6d3a..6ab9f3faa 100644
--- a/proc/info.c
+++ b/proc/info.c
@@ -24,6 +24,7 @@
#include <sys/mman.h>
#include <hurd/hurd_types.h>
#include <stdlib.h>
+#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <sys/resource.h>
@@ -1017,3 +1018,43 @@ S_proc_getnports (struct proc *callerp,
return err;
}
+
+/* Implement proc_set_path as described in <hurd/process.defs>. */
+kern_return_t
+S_proc_set_exe (struct proc *p,
+ char *path)
+{
+ char *copy;
+
+ if (!p)
+ return EOPNOTSUPP;
+
+ copy = strdup(path);
+ if (! copy)
+ return ENOMEM;
+
+ free(p->exe);
+ p->exe = copy;
+ return 0;
+}
+
+/* Implement proc_get_path as described in <hurd/process.defs>. */
+kern_return_t
+S_proc_get_exe (struct proc *callerp,
+ pid_t pid,
+ char *path)
+{
+ struct proc *p = pid_find (pid);
+
+ /* No need to check CALLERP here; we don't use it. */
+
+ if (!p)
+ return ESRCH;
+
+ if (p->exe)
+ snprintf (path, 1024 /* XXX */, "%s", p->exe);
+ else
+ path[0] = 0;
+ return 0;
+}
+
diff --git a/proc/mgt.c b/proc/mgt.c
index 354f37843..d92bf5285 100644
--- a/proc/mgt.c
+++ b/proc/mgt.c
@@ -223,6 +223,8 @@ S_proc_child (struct proc *parentp,
childp->start_code = parentp->start_code;
childp->end_code = parentp->end_code;
}
+ if (! childp->exe && parentp->exe)
+ childp->exe = strdup (parentp->exe);
if (MACH_PORT_VALID (parentp->p_task_namespace))
{
@@ -860,6 +862,8 @@ process_has_exited (struct proc *p)
if (!--p->p_login->l_refcnt)
free (p->p_login);
+ free (p->exe);
+ p->exe = NULL;
ids_rele (p->p_id);
diff --git a/proc/proc.h b/proc/proc.h
index b33845d96..a974f629e 100644
--- a/proc/proc.h
+++ b/proc/proc.h
@@ -68,6 +68,7 @@ struct proc
pthread_cond_t p_wakeup;
/* Miscellaneous information */
+ char *exe; /* path to binary executable */
vm_address_t p_argv, p_envp;
vm_address_t start_code; /* all executable segments are in this range */
vm_address_t end_code;