summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/kern/kern_exit.c10
-rw-r--r--sys/kern/kern_fork.c12
-rw-r--r--sys/sys/proc.h46
3 files changed, 32 insertions, 36 deletions
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index ad9d12bfab8..d925d666908 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_exit.c,v 1.12 1997/11/06 05:58:16 csapuntz Exp $ */
+/* $OpenBSD: kern_exit.c,v 1.13 1999/01/10 02:20:20 niklas Exp $ */
/* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */
/*
@@ -244,11 +244,11 @@ exit1(p, rv)
p->p_pctcpu = 0;
/*
- * Notify parent that we're gone. If parent has the P_NOCLDWAIT
- * flag set, notify process 1 instead (and hope it will handle
- * this situation).
+ * Notify parent that we're gone. If we have P_NOWAIT or parent has
+ * the P_NOCLDWAIT flag set, notify process 1 instead (and hope it
+ * will handle this situation).
*/
- if (p->p_pptr->p_flag & P_NOCLDWAIT) {
+ if ((p->p_flag & P_NOZOMBIE) || (p->p_pptr->p_flag & P_NOCLDWAIT)) {
struct proc *pp = p->p_pptr;
proc_reparent(p, initproc);
/*
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index c0b75327368..086b76a755a 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_fork.c,v 1.11 1997/08/01 22:54:49 deraadt Exp $ */
+/* $OpenBSD: kern_fork.c,v 1.12 1999/01/10 02:20:20 niklas Exp $ */
/* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */
/*
@@ -64,12 +64,6 @@ int nprocs = 1; /* process 0 */
int randompid; /* when set to 1, pid's go random */
pid_t lastpid;
-#define ISFORK 0
-#define ISVFORK 1
-#define ISRFORK 2
-
-int fork1 __P((struct proc *, int, int, register_t *));
-
/*ARGSUSED*/
int
sys_fork(p, v, retval)
@@ -126,8 +120,6 @@ fork1(p1, forktype, rforkflags, retval)
return (EINVAL);
if (rforkflags & RFFDG)
dupfd = 1;
- if (rforkflags & RFNOWAIT)
- return (EINVAL); /* XXX unimplimented */
if (rforkflags & RFCFDG)
cleanfd = 1;
}
@@ -268,7 +260,7 @@ again:
LIST_INSERT_AFTER(p1, p2, p_pglist);
p2->p_pptr = p1;
if (rforkflags & RFNOWAIT) {
- /* XXX should we do anything? */
+ p2->p_flag |= P_NOZOMBIE;
} else {
LIST_INSERT_HEAD(&p1->p_children, p2, p_sibling);
}
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
index 0f2a4fa9f08..d8f714fdb05 100644
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: proc.h,v 1.21 1999/01/05 00:43:20 deraadt Exp $ */
+/* $OpenBSD: proc.h,v 1.22 1999/01/10 02:20:19 niklas Exp $ */
/* $NetBSD: proc.h,v 1.44 1996/04/22 01:23:21 christos Exp $ */
/*-
@@ -211,31 +211,32 @@ struct proc {
#define SZOMB 5 /* Awaiting collection by parent. */
/* These flags are kept in p_flag. */
-#define P_ADVLOCK 0x00001 /* Process may hold a POSIX advisory lock. */
-#define P_CONTROLT 0x00002 /* Has a controlling terminal. */
-#define P_INMEM 0x00004 /* Loaded into memory. */
-#define P_NOCLDSTOP 0x00008 /* No SIGCHLD when children stop. */
-#define P_PPWAIT 0x00010 /* Parent is waiting for child to exec/exit. */
-#define P_PROFIL 0x00020 /* Has started profiling. */
-#define P_SELECT 0x00040 /* Selecting; wakeup/waiting danger. */
-#define P_SINTR 0x00080 /* Sleep is interruptible. */
-#define P_SUGID 0x00100 /* Had set id privileges since last exec. */
-#define P_SYSTEM 0x00200 /* System proc: no sigs, stats or swapping. */
-#define P_TIMEOUT 0x00400 /* Timing out during sleep. */
-#define P_TRACED 0x00800 /* Debugged process being traced. */
-#define P_WAITED 0x01000 /* Debugging process has waited for child. */
-#define P_WEXIT 0x02000 /* Working on exiting. */
-#define P_EXEC 0x04000 /* Process called exec. */
+#define P_ADVLOCK 0x000001 /* Proc may hold a POSIX adv. lock. */
+#define P_CONTROLT 0x000002 /* Has a controlling terminal. */
+#define P_INMEM 0x000004 /* Loaded into memory. */
+#define P_NOCLDSTOP 0x000008 /* No SIGCHLD when children stop. */
+#define P_PPWAIT 0x000010 /* Parent waits for child exec/exit. */
+#define P_PROFIL 0x000020 /* Has started profiling. */
+#define P_SELECT 0x000040 /* Selecting; wakeup/waiting danger. */
+#define P_SINTR 0x000080 /* Sleep is interruptible. */
+#define P_SUGID 0x000100 /* Had set id privs since last exec. */
+#define P_SYSTEM 0x000200 /* No sigs, stats or swapping. */
+#define P_TIMEOUT 0x000400 /* Timing out during sleep. */
+#define P_TRACED 0x000800 /* Debugged process being traced. */
+#define P_WAITED 0x001000 /* Debugging proc has waited for child. */
+#define P_WEXIT 0x002000 /* Working on exiting. */
+#define P_EXEC 0x004000 /* Process called exec. */
/* Should be moved to machine-dependent areas. */
-#define P_OWEUPC 0x08000 /* Owe process an addupc() call at next ast. */
+#define P_OWEUPC 0x008000 /* Owe proc an addupc() at next ast. */
/* XXX Not sure what to do with these, yet. */
-#define P_FSTRACE 0x10000 /* tracing via file system (elsewhere?) */
-#define P_SSTEP 0x20000 /* process needs single-step fixup ??? */
-#define P_SUGIDEXEC 0x40000 /* last execve() was a setuid/setgid execve() */
+#define P_FSTRACE 0x010000 /* tracing via fs (elsewhere?) */
+#define P_SSTEP 0x020000 /* proc needs single-step fixup ??? */
+#define P_SUGIDEXEC 0x040000 /* last execve() was set[ug]id */
-#define P_NOCLDWAIT 0x80000 /* No zombies if child dies (assign to pid 1) */
+#define P_NOCLDWAIT 0x080000 /* Let pid 1 wait for my children */
+#define P_NOZOMBIE 0x100000 /* Pid 1 waits for me instead of dad */
/*
* MOVE TO ucred.h?
@@ -321,6 +322,9 @@ void unsleep __P((struct proc *));
void wakeup __P((void *chan));
void exit1 __P((struct proc *, int));
int fork1 __P((struct proc *, int, int, register_t *));
+#define ISFORK 0
+#define ISVFORK 1
+#define ISRFORK 2
void kmeminit __P((void));
void rqinit __P((void));
int groupmember __P((gid_t, struct ucred *));