summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael I. Bushnell <mib@gnu.org>1996-03-20 16:07:23 +0000
committerMichael I. Bushnell <mib@gnu.org>1996-03-20 16:07:23 +0000
commit669c6d5d2aa0062ea34854d1a6a4cea2f508729f (patch)
tree962136d21dcfc249d4f95dbf48858c6ad4f09c0c
parent1b9d6caaff22f4ea1d797328ee256a352ddf72c6 (diff)
(waiting_parent_cares): Delete function.
Don't include "interrupt_S.h". (alent_parent): Unconditionally enqueue zombie. Use condition_broadcast instead of continuation stuff. (S_interrupt_operation): Delete function. (abort_wait): Delete function. (reparent_zombies): Likewise. (S_proc_mark_stop): Likewise. (S_proc_wait): Use condition_wait instead of continuation stuff; never return EBUSY.
-rw-r--r--proc/wait.c96
1 files changed, 13 insertions, 83 deletions
diff --git a/proc/wait.c b/proc/wait.c
index 5b1c7bbf..57fc4cad 100644
--- a/proc/wait.c
+++ b/proc/wait.c
@@ -1,5 +1,5 @@
/* Implementation of wait
- Copyright (C) 1994, 1995 Free Software Foundation
+ Copyright (C) 1994, 1995, 1996 Free Software Foundation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -32,7 +32,6 @@
#include "process_S.h"
#include "process_reply_U.h"
#include "ourmsg_U.h"
-#include "interrupt_S.h"
#include <mach/mig_errors.h>
@@ -48,15 +47,6 @@ waiter_cares (pid_t wait_pid, pid_t mypgrp,
(wait_pid == WAIT_MYPGRP && pgrp == mypgrp));
}
-/* Return nonzero iff PARENT is waiting for PID/PGRP. */
-static inline int
-waiting_parent_cares (struct proc *parent, pid_t pid, pid_t pgrp)
-{
- struct wait_c *w = &parent->p_continuation.wait_c;
- return waiter_cares (w->pid, parent->p_pgrp->pg_pgid, pid, pgrp);
-}
-
-
/* A process is dying. Send SIGCHLD to the parent. Check if the parent is
waiting for us to exit; if so wake it up, otherwise, enter us as a
zombie. */
@@ -72,19 +62,10 @@ alert_parent (struct proc *p)
if (p->p_parent->p_waiting)
{
- struct wait_c *w = &p->p_parent->p_continuation.wait_c;
- if (waiting_parent_cares (p->p_parent, p->p_pid, p->p_pgrp->pg_pgid))
- {
- struct rusage ru;
-
- bzero (&ru, sizeof (struct rusage));
- proc_wait_reply (w->reply_port, w->reply_port_type, 0,
- p->p_status, ru, p->p_pid);
- p->p_parent->p_waiting = 0;
- return;
- }
+ condition_broadcast (&p->p_parent->p_wakeup);
+ p->p_parent->p_waiting = 0;
}
-
+
z = malloc (sizeof (struct zombie));
z->pid = p->p_pid;
@@ -104,7 +85,7 @@ reparent_zombies (struct proc *p)
{
struct zombie *z, *prevz;
struct wait_c *w = &startup_proc->p_continuation.wait_c;
- int initwoken = 0, initsignalled = 0;
+ int initsignalled = 0;
for (z = zombie_list, prevz = 0; z; prevz = z, z = z->next)
{
@@ -118,33 +99,14 @@ reparent_zombies (struct proc *p)
initsignalled = 1;
}
- if (initwoken || !startup_proc->p_waiting)
- continue;
-
- if (waiting_parent_cares (startup_proc, z->pid, z->pgrp))
+ if (startup_proc->p_waiting)
{
- proc_wait_reply (w->reply_port, w->reply_port_type, 0,
- z->exit_status, z->ru, z->pid);
+ condition_broadcast (&startup_proc->p_wakeup);
startup_proc->p_waiting = 0;
- (prevz ? prevz->next : zombie_list) = z->next;
- free (z);
- initwoken = 1;
}
}
}
-/* Cause the pending wait operation of process P to immediately
- return. */
-void
-abort_wait (struct proc *p)
-{
- struct wait_c *w = &p->p_continuation.wait_c;
- struct rusage ru;
-
- proc_wait_reply (w->reply_port, w->reply_port_type, EINTR,
- 0, ru, 0);
- p->p_waiting = 0;
-}
/* Implement proc_wait as described in <hurd/proc.defs>. */
kern_return_t
@@ -160,6 +122,7 @@ S_proc_wait (struct proc *p,
struct wait_c *w;
struct zombie *z, *prevz;
+ start_over:
for (z = zombie_list, prevz = 0; z; prevz = z, z = z->next)
{
if (z->parent == p && waiter_cares (pid, p->p_pgrp->pg_pgid,
@@ -222,16 +185,9 @@ S_proc_wait (struct proc *p,
if (options & WNOHANG)
return EWOULDBLOCK;
- if (p->p_waiting || p->p_msgportwait)
- return EBUSY;
-
p->p_waiting = 1;
- w = &p->p_continuation.wait_c;
- w->reply_port = reply_port;
- w->reply_port_type = reply_port_type;
- w->pid = pid;
- w->options = options;
- return MIG_NO_REPLY;
+ condition_wait (&p->p_wakeup, &global_lock);
+ goto start_over;
}
/* Implement proc_mark_stop as described in <hurd/proc.defs>. */
@@ -245,19 +201,10 @@ S_proc_mark_stop (struct proc *p,
if (p->p_parent->p_waiting)
{
- struct wait_c *w = &p->p_parent->p_continuation.wait_c;
- if (((w->options & WUNTRACED) || p->p_traced)
- && waiting_parent_cares (p->p_parent, p->p_pid, p->p_pgrp->pg_pgid))
- {
- struct rusage ru;
- bzero (&ru, sizeof (struct rusage));
- proc_wait_reply (w->reply_port, w->reply_port_type, 0,
- p->p_status, ru, p->p_pid);
- p->p_parent->p_waiting = 0;
- p->p_waited = 1;
- }
+ condition_broadcast (&p->p_parent->p_wakeup);
+ p->p_parent->p_waiting = 0;
}
-
+
if (!p->p_parent->p_nostopcld)
send_signal (p->p_parent->p_msgport, SIGCHLD, p->p_parent->p_task);
@@ -315,20 +262,3 @@ zombie_check_pid (pid_t pid)
return 0;
}
-/* Implement interrupt_operation as described in <hurd/interrupt.defs>. */
-kern_return_t
-S_interrupt_operation (mach_port_t object,
- mach_port_seqno_t seqno)
-{
- struct proc *p = reqport_find (object);
-
- if (!p)
- return EOPNOTSUPP;
-
- if (p->p_waiting)
- abort_wait (p);
- if (p->p_msgportwait)
- abort_getmsgport (p);
-
- return 0;
-}