summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_fork.c
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2004-12-14 07:20:03 +0000
committerphk <phk@FreeBSD.org>2004-12-14 07:20:03 +0000
commite622b9bcba58c68642dfd3b9c7654dce32990367 (patch)
treed5213f95c16764c73163213eb2df16556c38d979 /sys/kern/kern_fork.c
parentccc36e1e1bd947bf91889ba35f5b3f2b4d3b22e1 (diff)
downloadFreeBSD-src-e622b9bcba58c68642dfd3b9c7654dce32990367.zip
FreeBSD-src-e622b9bcba58c68642dfd3b9c7654dce32990367.tar.gz
Add new function fdunshare() which encapsulates the necessary light magic
for ensuring that a process' filedesc is not shared with anybody. Use it in the two places which previously had private implmentations. This collects all fd_refcnt handling in kern_descrip.c
Diffstat (limited to 'sys/kern/kern_fork.c')
-rw-r--r--sys/kern/kern_fork.c14
1 files changed, 2 insertions, 12 deletions
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index ae8cce3..3178c10 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -233,18 +233,8 @@ fork1(td, flags, pages, procp)
/*
* Unshare file descriptors (from parent).
*/
- if (flags & RFFDG) {
- FILEDESC_LOCK_FAST(p1->p_fd);
- if (p1->p_fd->fd_refcnt > 1) {
- struct filedesc *newfd;
-
- FILEDESC_UNLOCK_FAST(p1->p_fd);
- newfd = fdcopy(p1->p_fd);
- fdfree(td);
- p1->p_fd = newfd;
- } else
- FILEDESC_UNLOCK_FAST(p1->p_fd);
- }
+ if (flags & RFFDG)
+ fdunshare(p1, td);
*procp = NULL;
return (0);
}
OpenPOWER on IntegriCloud