diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2008-11-11 02:13:15 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2008-11-11 02:13:15 +0000 |
commit | 5f71cbc6b422c15be464aa61934d622323af56c7 (patch) | |
tree | 1d9b13af9d0d23880703b6eeca21e1c6cf270029 | |
parent | 1e3bcc3c27e2bb29f3f3cdd12b8f070007d1e858 (diff) |
slightly optimized the ptrace stat allocation to only happen when needed.
ok deraadt
-rw-r--r-- | sys/kern/kern_fork.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 8c00895a41f..76d868fe0a4 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_fork.c,v 1.100 2008/11/09 05:13:55 deraadt Exp $ */ +/* $OpenBSD: kern_fork.c,v 1.101 2008/11/11 02:13:14 tedu Exp $ */ /* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */ /* @@ -181,7 +181,7 @@ fork1(struct proc *p1, int exitsig, int flags, void *stack, size_t stacksize, int s; extern void endtsleep(void *); extern void realitexpire(void *); - struct ptrace_state *newptstat; + struct ptrace_state *newptstat = NULL; #if NSYSTRACE > 0 void *newstrp = NULL; #endif @@ -387,7 +387,8 @@ fork1(struct proc *p1, int exitsig, int flags, void *stack, size_t stacksize, forkstat.sizkthread += vm->vm_dsize + vm->vm_ssize; } - newptstat = malloc(sizeof(struct ptrace_state), M_SUBPROC, M_WAITOK); + if (p2->p_flag & P_TRACED && flags & FORK_FORK) + newptstat = malloc(sizeof(*newptstat), M_SUBPROC, M_WAITOK); #if NSYSTRACE > 0 if (ISSET(p1->p_flag, P_SYSTRACE)) newstrp = systrace_getproc(); |