summaryrefslogtreecommitdiff
path: root/proc
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2000-03-12 08:53:12 +0000
committerRoland McGrath <roland@gnu.org>2000-03-12 08:53:12 +0000
commit4f8655657b7afd3628283be6bcb114806423cd32 (patch)
treeb0d29d25580c8dd9eb117c8a7e4d543f22e04151 /proc
parent58d9238df8bd21eefc0f9836211a3365ba4d6261 (diff)
2000-03-12 Roland McGrath <roland@baalperazim.frob.com>
* mgt.c (allocate_proc): Don't do mach_port_request_notification here. (proc_death_notify): New function, do it here instead. (complete_proc): Call proc_death_notify. * main.c (main): Call proc_death_notify on STARTUP_PROC after we have set its task port. * proc.h: Declare proc_death_notify.
Diffstat (limited to 'proc')
-rw-r--r--proc/main.c3
-rw-r--r--proc/mgt.c30
-rw-r--r--proc/proc.h1
3 files changed, 24 insertions, 10 deletions
diff --git a/proc/main.c b/proc/main.c
index ced0e5a7..6d74e1de 100644
--- a/proc/main.c
+++ b/proc/main.c
@@ -1,5 +1,5 @@
/* Initialization of the proc server
- Copyright (C) 1993, 1994, 1995, 1996, 1997, 1999 Free Software Foundation
+ Copyright (C) 1993,94,95,96,97,99,2000 Free Software Foundation, Inc.
This file is part of the GNU Hurd.
@@ -99,6 +99,7 @@ main (int argc, char **argv, char **envp)
_hurd_port_set (&_hurd_ports[INIT_PORT_AUTH], authserver);
mach_port_deallocate (mach_task_self (), boot);
+ proc_death_notify (startup_proc);
add_proc_to_hash (startup_proc); /* Now that we have the task port. */
/* Set our own argv and envp locations. */
diff --git a/proc/mgt.c b/proc/mgt.c
index 551885de..283e660b 100644
--- a/proc/mgt.c
+++ b/proc/mgt.c
@@ -1,5 +1,5 @@
/* Process management
- Copyright (C) 1992,93,94,95,96,99 Free Software Foundation, Inc.
+ Copyright (C) 1992,93,94,95,96,99,2000 Free Software Foundation, Inc.
This file is part of the GNU Hurd.
@@ -495,7 +495,6 @@ struct proc *
allocate_proc (task_t task)
{
struct proc *p;
- mach_port_t foo;
/* Pid 0 is us; pid 1 is init. We handle those here specially;
all other processes inherit from init here (though proc_child
@@ -504,13 +503,6 @@ allocate_proc (task_t task)
ports_create_port (proc_class, proc_bucket, sizeof (struct proc), &p);
p->p_task = task;
-
- mach_port_request_notification (mach_task_self (), p->p_task,
- MACH_NOTIFY_DEAD_NAME, 1, p->p_pi.port_right,
- MACH_MSG_TYPE_MAKE_SEND_ONCE, &foo);
- if (foo != MACH_PORT_NULL)
- mach_port_deallocate (mach_task_self (), foo);
-
p->p_msgport = MACH_PORT_NULL;
condition_init (&p->p_wakeup);
@@ -566,6 +558,25 @@ create_startup_proc (void)
return p;
}
+/* Request a dead-name notification for P's task port. */
+
+void
+proc_death_notify (struct proc *p)
+{
+ error_t err;
+ mach_port_t old;
+
+ err = mach_port_request_notification (mach_task_self (), p->p_task,
+ MACH_NOTIFY_DEAD_NAME, 1,
+ p->p_pi.port_right,
+ MACH_MSG_TYPE_MAKE_SEND_ONCE,
+ &old);
+ assert_perror (err);
+
+ if (old != MACH_PORT_NULL)
+ mach_port_deallocate (mach_task_self (), old);
+}
+
/* Complete a new process that has been allocated but not entirely initialized.
This gets called for every process except startup_proc (PID 1). */
void
@@ -607,6 +618,7 @@ complete_proc (struct proc *p, pid_t pid)
p->p_pgrp = startup_proc->p_pgrp;
+ proc_death_notify (p);
add_proc_to_hash (p);
join_pgrp (p);
}
diff --git a/proc/proc.h b/proc/proc.h
index 0022b132..1344df03 100644
--- a/proc/proc.h
+++ b/proc/proc.h
@@ -192,6 +192,7 @@ int pidfree (pid_t);
struct proc *create_startup_proc (void);
struct proc *allocate_proc (task_t);
+void proc_death_notify (struct proc *);
void complete_proc (struct proc *, pid_t);
void leave_pgrp (struct proc *);