summaryrefslogtreecommitdiff
path: root/sys/kern/kern_exec.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern/kern_exec.c')
-rw-r--r--sys/kern/kern_exec.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index 670d5dddd117..3fe2ab367b7f 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -281,13 +281,16 @@ interpret:
* For security and other reasons, the file descriptor table cannot
* be shared after an exec.
*/
+ FILEDESC_LOCK(p->p_fd);
if (p->p_fd->fd_refcnt > 1) {
struct filedesc *tmp;
tmp = fdcopy(td);
+ FILEDESC_UNLOCK(p->p_fd);
fdfree(td);
p->p_fd = tmp;
- }
+ } else
+ FILEDESC_UNLOCK(p->p_fd);
/*
* For security and other reasons, signal handlers cannot