From e622b9bcba58c68642dfd3b9c7654dce32990367 Mon Sep 17 00:00:00 2001 From: phk Date: Tue, 14 Dec 2004 07:20:03 +0000 Subject: 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 --- sys/kern/kern_exec.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'sys/kern/kern_exec.c') diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index e21cb00..40e0f0a 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -465,16 +465,7 @@ interpret: * For security and other reasons, the file descriptor table cannot * be shared after an exec. */ - FILEDESC_LOCK_FAST(p->p_fd); - if (p->p_fd->fd_refcnt > 1) { - struct filedesc *tmp; - - FILEDESC_UNLOCK_FAST(p->p_fd); - tmp = fdcopy(p->p_fd); - fdfree(td); - p->p_fd = tmp; - } else - FILEDESC_UNLOCK_FAST(p->p_fd); + fdunshare(p, td); /* * Malloc things before we need locks. -- cgit v1.1