diff options
author | pjd <pjd@FreeBSD.org> | 2012-06-19 22:21:59 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2012-06-19 22:21:59 +0000 |
commit | 81ad62d5c5ada4f045f95f14c8e2346b0fbd8e6c (patch) | |
tree | 10ee8b46a0db9f178c6e45564496a9aac9ad30dc /sys/kern/kern_fork.c | |
parent | 571562fffb435a478f0591879dd19fe9227cb52e (diff) | |
download | FreeBSD-src-81ad62d5c5ada4f045f95f14c8e2346b0fbd8e6c.zip FreeBSD-src-81ad62d5c5ada4f045f95f14c8e2346b0fbd8e6c.tar.gz |
The falloc() function obtains two references to newly created 'fp'.
On success we have to drop one after procdesc_finit() and on failure
we have to close allocated slot with fdclose(), which also drops one
reference for us and drop the remaining reference with fdrop().
Without this change closing process descriptor didn't result in killing
pdfork(2)ed child.
Reviewed by: rwatson
MFC after: 1 month
Diffstat (limited to 'sys/kern/kern_fork.c')
-rw-r--r-- | sys/kern/kern_fork.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index f23c204..6cb95cd 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -921,8 +921,10 @@ fork1(struct thread *td, int flags, int pages, struct proc **procp, */ *procp = newproc; #ifdef PROCDESC - if (flags & RFPROCDESC) + if (flags & RFPROCDESC) { procdesc_finit(newproc->p_procdesc, fp_procdesc); + fdrop(fp_procdesc, td); + } #endif racct_proc_fork_done(newproc); return (0); @@ -944,8 +946,10 @@ fail1: vmspace_free(vm2); uma_zfree(proc_zone, newproc); #ifdef PROCDESC - if (((flags & RFPROCDESC) != 0) && (fp_procdesc != NULL)) + if (((flags & RFPROCDESC) != 0) && (fp_procdesc != NULL)) { + fdclose(td->td_proc->p_fd, fp_procdesc, *procdescp, td); fdrop(fp_procdesc, td); + } #endif pause("fork", hz / 2); return (error); |