From 4f8655657b7afd3628283be6bcb114806423cd32 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 12 Mar 2000 08:53:12 +0000 Subject: 2000-03-12 Roland McGrath * 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. --- proc/mgt.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'proc/mgt.c') 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); } -- cgit v1.2.3