Source-Changes-HG archive

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

[src/trunk]: src/sys/kern do_sys_wait: clear rusage, instead of returning gar...



details:   https://anonhg.NetBSD.org/src/rev/ccb1d384896b
branches:  trunk
changeset: 748687:ccb1d384896b
user:      rmind <rmind%NetBSD.org@localhost>
date:      Sun Nov 01 21:05:30 2009 +0000

description:
do_sys_wait: clear rusage, instead of returning garbage.  Patch from
dholland@ via PR/40717, with minor change by me.

diffstat:

 sys/kern/kern_exit.c |  15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diffs (43 lines):

diff -r 453b49a9a508 -r ccb1d384896b sys/kern/kern_exit.c
--- a/sys/kern/kern_exit.c      Sun Nov 01 20:59:24 2009 +0000
+++ b/sys/kern/kern_exit.c      Sun Nov 01 21:05:30 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_exit.c,v 1.223 2009/10/22 22:28:57 rmind Exp $    */
+/*     $NetBSD: kern_exit.c,v 1.224 2009/11/01 21:05:30 rmind Exp $    */
 
 /*-
  * Copyright (c) 1998, 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.223 2009/10/22 22:28:57 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.224 2009/11/01 21:05:30 rmind Exp $");
 
 #include "opt_ktrace.h"
 #include "opt_perfctrs.h"
@@ -684,17 +684,20 @@
 
        if (child->p_stat == SZOMB) {
                /* proc_free() will release the proc_lock. */
-               *was_zombie = 1;
-               if (options & WNOWAIT)
+               if (options & WNOWAIT) {
                        mutex_exit(proc_lock);
-               else {
+                       memset(ru, 0, sizeof(*ru));
+               } else {
                        proc_free(child, ru);
                }
+               *was_zombie = 1;
        } else {
                /* Child state must have been SSTOP. */
+               mutex_exit(proc_lock);
+
                *was_zombie = 0;
-               mutex_exit(proc_lock);
                *status = W_STOPCODE(*status);
+               memset(ru, 0, sizeof(*ru));
        }
 
        return 0;



Home | Main Index | Thread Index | Old Index