From 4473d16e7cdad08eccad95f5920e1aa171d5512d Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Fri, 21 Feb 2014 14:58:21 +0100 Subject: exec: provide a meaningful name for new tasks The name will be used in error messages printed by the kernel. This makes attributing the errors to processes possible. * exec/exec.c (do_exec): Set the name of the new task. --- exec/exec.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'exec') diff --git a/exec/exec.c b/exec/exec.c index fad94926..e693f633 100644 --- a/exec/exec.c +++ b/exec/exec.c @@ -1151,14 +1151,29 @@ do_exec (file_t file, } boot->user_entry = e.entry; /* already adjusted in `load' */ - /* Set the start_code and end_code values for this process. - /hurd/exec is used to start /hurd/proc, so at this point there is + /* /hurd/exec is used to start /hurd/proc, so at this point there is no proc server, so we need to be careful here. */ if (boot->portarray[INIT_PORT_PROC] != MACH_PORT_NULL) - e.error = proc_set_code (boot->portarray[INIT_PORT_PROC], - e.start_code, e.end_code); - if (e.error) - goto out; + { + /* Set the start_code and end_code values for this process. */ + e.error = proc_set_code (boot->portarray[INIT_PORT_PROC], + e.start_code, e.end_code); + if (e.error) + goto out; + + pid_t pid; + e.error = proc_task2pid (boot->portarray[INIT_PORT_PROC], + newtask, &pid); + if (e.error) + goto out; + + char *name; + if (asprintf (&name, "%s(%d)", argv, pid) > 0) + { + task_set_name (newtask, name); + free (name); + } + } /* Create the initial thread. */ e.error = thread_create (newtask, &thread); -- cgit v1.2.3