bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: proc changes for rusage


From: Neal H Walfield
Subject: Re: proc changes for rusage
Date: Tue, 7 Aug 2001 00:41:44 +0200
User-agent: Mutt/1.3.18i

On Sun, Aug 05, 2001 at 03:29:43PM -0400, Roland McGrath wrote:
> Please test the changes I've just checked into proc.

Several bugs.

2001-08-07  Neal H Walfield  <neal@cs.uml.edu>

        * msg.c (allocate_proc): Do not overwrite the port_info
        structure that we just initialized.
        * wait.c (reap): Take a second argument, return_pid and use it;
        not all callers want PID_STATUS set to PID.
        (S_proc_wait): Avoid the really convoluted logic at the
        beginning of REAP and reintroduce CHILD_READY.
        Use the new calling conventions of REAP.


Index: proc/mgt.c
===================================================================
RCS file: /cvs/hurd/proc/mgt.c,v
retrieving revision 1.62
diff -u -p -r1.62 mgt.c
--- proc/mgt.c  2001/08/04 23:32:33     1.62
+++ proc/mgt.c  2001/08/06 22:14:33
@@ -555,7 +555,8 @@ allocate_proc (task_t task)
   if (err)
     return NULL;
 
-  memset (p, 0, sizeof *p);
+  memset ((void *) p + sizeof (struct port_info), 0,
+         sizeof *p - sizeof (struct port_info));
   p->p_task = task;
   p->p_msgport = MACH_PORT_NULL;
 
Index: proc/wait.c
===================================================================
RCS file: /cvs/hurd/proc/wait.c,v
retrieving revision 1.28
diff -u -p -r1.28 wait.c
--- proc/wait.c 2001/08/05 19:02:55     1.28
+++ proc/wait.c 2001/08/06 22:14:33
@@ -172,18 +172,29 @@ S_proc_wait (struct proc *p,
 {
   int cancel;
 
-  int reap (struct proc *child)
+  int reap (struct proc *child, pid_t return_pid)
     {
-      if (child->p_waited
-         || (!child->p_dead
-             && (!child->p_stopped
-                 || !(child->p_traced || (options & WUNTRACED)))))
+      int child_ready (void)
+        {
+         if (child->p_waited)
+           return 0;
+          if (child->p_dead)
+           return 1;
+          if (!child->p_stopped)
+           return 0;
+          if (child->p_traced || (options & WUNTRACED))
+           return 1;
+          return 0;
+        }
+
+      if (! child_ready ())
        return 0;
+
       child->p_waited = 1;
       *status = child->p_status;
       *sigcode = child->p_sigcode;
       *ru = child->p_rusage; /* all zeros if !p_dead */
-      *pid_status = pid;
+      *pid_status = return_pid;
       if (child->p_dead)
        complete_exit (child);
       return 1;
@@ -203,7 +214,7 @@ S_proc_wait (struct proc *p,
       struct proc *child = pid_find_allow_zombie (pid);
       if (!child || child->p_parent != p)
        return ECHILD;
-      if (reap (child))
+      if (reap (child, pid))
        return 0;
     }
   else
@@ -215,7 +226,7 @@ S_proc_wait (struct proc *p,
        if (waiter_cares (pid, p->p_pgrp->pg_pgid,
                          child->p_pid, child->p_pgrp->pg_pgid))
          {
-           if (reap (child))
+           if (reap (child, child->p_pid))
              return 0;
            had_a_match = 1;
          }

Attachment: pgpG7poMk92jY.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]