From 1888e2289d471cdb8fdacb3ad2b65e353a7ac11a Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Wed, 14 Apr 2010 21:46:14 +0000 Subject: [PATCH] bonefish+mmlr: The O_CLOEXEC open mode wasn't actually set in the close-on-exec bitmap causing all files opened with O_CLOEXEC (like done in the storage kit classes) to still be inherited. This caused for example to be unable to unmount volumes when opening apps while Tracker touched some files (i.e. copying some large files) since these apps would inherit the file descriptor and therefore keep the volume busy. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36273 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/fs/vfs.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/system/kernel/fs/vfs.cpp b/src/system/kernel/fs/vfs.cpp index c6bcd46c47..28ece4c231 100644 --- a/src/system/kernel/fs/vfs.cpp +++ b/src/system/kernel/fs/vfs.cpp @@ -2857,12 +2857,17 @@ get_new_fd(int type, struct fs_mount* mount, struct vnode* vnode, descriptor->type = type; descriptor->open_mode = openMode; - fd = new_fd(get_current_io_context(kernel), descriptor); + io_context* context = get_current_io_context(kernel); + fd = new_fd(context, descriptor); if (fd < 0) { free(descriptor); return B_NO_MORE_FDS; } + mutex_lock(&context->io_mutex); + fd_set_close_on_exec(context, fd, (openMode & O_CLOEXEC) != 0); + mutex_unlock(&context->io_mutex); + return fd; }