summaryrefslogtreecommitdiff
path: root/sys/kern/kern_fork.c
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2014-03-22 06:05:46 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2014-03-22 06:05:46 +0000
commit58e167147475b8367a25672642fd1841a7c4c1e6 (patch)
tree39517e7dd439b7734c981f57eb67360f7c017e46 /sys/kern/kern_fork.c
parent187690a3e0724e51c20a94a626cc80a07134107c (diff)
Move p_sigacts from struct proc to struct process.
testing help mpi@
Diffstat (limited to 'sys/kern/kern_fork.c')
-rw-r--r--sys/kern/kern_fork.c56
1 files changed, 27 insertions, 29 deletions
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index d8a462dc907..22da80f01d6 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_fork.c,v 1.158 2014/02/12 05:47:36 guenther Exp $ */
+/* $OpenBSD: kern_fork.c,v 1.159 2014/03/22 06:05:45 guenther Exp $ */
/* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */
/*
@@ -78,7 +78,7 @@ void fork_return(void *);
void tfork_child_return(void *);
int pidtaken(pid_t);
-void process_new(struct proc *, struct process *);
+void process_new(struct proc *, struct process *, int);
void
fork_return(void *arg)
@@ -152,7 +152,7 @@ tfork_child_return(void *arg)
* Allocate and initialize a new process.
*/
void
-process_new(struct proc *p, struct process *parent)
+process_new(struct proc *p, struct process *parent, int flags)
{
struct process *pr;
@@ -195,6 +195,21 @@ process_new(struct proc *p, struct process *parent)
p->p_p = pr;
+ /*
+ * Create signal actions for the child process.
+ */
+ if (flags & FORK_SIGHAND)
+ pr->ps_sigacts = sigactsshare(parent);
+ else
+ pr->ps_sigacts = sigactsinit(parent);
+
+ if (parent->ps_flags & PS_PROFIL)
+ startprofclock(pr);
+ if ((flags & FORK_PTRACE) && (parent->ps_flags & PS_TRACED))
+ atomic_setbits_int(&pr->ps_flags, PS_TRACED);
+ if (flags & FORK_NOZOMBIE)
+ atomic_setbits_int(&pr->ps_flags, PS_NOZOMBIE);
+
/* it's sufficiently inited to be globally visible */
LIST_INSERT_HEAD(&allprocess, pr, ps_list);
}
@@ -295,16 +310,6 @@ fork1(struct proc *curp, int flags, void *stack, pid_t *tidptr,
p->p_stat = SIDL; /* protect against others */
p->p_flag = 0;
- p->p_xstat = 0;
-
- if (flags & FORK_THREAD) {
- atomic_setbits_int(&p->p_flag, P_THREAD);
- p->p_p = pr = curpr;
- pr->ps_refcnt++;
- } else {
- process_new(p, curpr);
- pr = p->p_p;
- }
/*
* Make a proc table entry for the new process.
@@ -321,19 +326,19 @@ fork1(struct proc *curp, int flags, void *stack, pid_t *tidptr,
*/
timeout_set(&p->p_sleep_to, endtsleep, p);
+ if (flags & FORK_THREAD) {
+ atomic_setbits_int(&p->p_flag, P_THREAD);
+ p->p_p = pr = curpr;
+ pr->ps_refcnt++;
+ } else {
+ process_new(p, curpr, flags);
+ pr = p->p_p;
+ }
+
/*
* Duplicate sub-structures as needed.
* Increase reference counts on shared objects.
*/
- if ((flags & FORK_THREAD) == 0) {
- if (curpr->ps_flags & PS_PROFIL)
- startprofclock(pr);
- if ((flags & FORK_PTRACE) && (curpr->ps_flags & PS_TRACED))
- atomic_setbits_int(&pr->ps_flags, PS_TRACED);
- if (flags & FORK_NOZOMBIE)
- atomic_setbits_int(&pr->ps_flags, PS_NOZOMBIE);
- }
-
if (flags & FORK_SHAREFILES)
p->p_fd = fdshare(curp);
else
@@ -361,13 +366,6 @@ fork1(struct proc *curp, int flags, void *stack, pid_t *tidptr,
*/
scheduler_fork_hook(curp, p);
- /*
- * Create signal actions for the child process.
- */
- if (flags & FORK_SIGHAND)
- p->p_sigacts = sigactsshare(curp);
- else
- p->p_sigacts = sigactsinit(curp);
if (flags & FORK_THREAD)
sigstkinit(&p->p_sigstk);