Source-Changes-HG archive

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

[src/trunk]: src/sys Add FORK_NOWAIT flag, which sets init as the parent of t...



details:   https://anonhg.NetBSD.org/src/rev/46e04695e6a0
branches:  trunk
changeset: 533939:46e04695e6a0
user:      pooka <pooka%NetBSD.org@localhost>
date:      Thu Jul 11 10:37:26 2002 +0000

description:
Add FORK_NOWAIT flag, which sets init as the parent of the forked
process. Useful for FreeBSD rfork() emulation.

ok'd by Christos

diffstat:

 sys/kern/kern_fork.c |  8 ++++----
 sys/sys/proc.h       |  3 ++-
 2 files changed, 6 insertions(+), 5 deletions(-)

diffs (46 lines):

diff -r bc87d63d816c -r 46e04695e6a0 sys/kern/kern_fork.c
--- a/sys/kern/kern_fork.c      Thu Jul 11 10:02:21 2002 +0000
+++ b/sys/kern/kern_fork.c      Thu Jul 11 10:37:26 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_fork.c,v 1.89 2002/06/17 16:22:50 christos Exp $  */
+/*     $NetBSD: kern_fork.c,v 1.90 2002/07/11 10:37:26 pooka Exp $     */
 
 /*-
  * Copyright (c) 1999, 2001 The NetBSD Foundation, Inc.
@@ -78,7 +78,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.89 2002/06/17 16:22:50 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.90 2002/07/11 10:37:26 pooka Exp $");
 
 #include "opt_ktrace.h"
 #include "opt_systrace.h"
@@ -407,8 +407,8 @@
        if (flags & FORK_PPWAIT)
                p2->p_flag |= P_PPWAIT;
        LIST_INSERT_AFTER(p1, p2, p_pglist);
-       p2->p_pptr = p1;
-       LIST_INSERT_HEAD(&p1->p_children, p2, p_sibling);
+       p2->p_pptr = (flags & FORK_NOWAIT) ? initproc : p1;
+       LIST_INSERT_HEAD(&p2->p_pptr->p_children, p2, p_sibling);
        LIST_INIT(&p2->p_children);
 
        callout_init(&p2->p_realit_ch);
diff -r bc87d63d816c -r 46e04695e6a0 sys/sys/proc.h
--- a/sys/sys/proc.h    Thu Jul 11 10:02:21 2002 +0000
+++ b/sys/sys/proc.h    Thu Jul 11 10:37:26 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: proc.h,v 1.140 2002/07/04 23:32:15 thorpej Exp $       */
+/*     $NetBSD: proc.h,v 1.141 2002/07/11 10:37:27 pooka Exp $ */
 
 /*-
  * Copyright (c) 1986, 1989, 1991, 1993
@@ -366,6 +366,7 @@
 #define        FORK_SHARECWD   0x04            /* Share cdir/rdir/cmask */
 #define        FORK_SHAREFILES 0x08            /* Share file descriptors */
 #define        FORK_SHARESIGS  0x10            /* Share signal actions */
+#define        FORK_NOWAIT     0x20            /* Make init the parent of the child */
 
 #define        PIDHASH(pid)    (&pidhashtbl[(pid) & pidhash])
 extern LIST_HEAD(pidhashhead, proc) *pidhashtbl;



Home | Main Index | Thread Index | Old Index