From 0fc976d9003f9e61913cf2eb648dfd59bc1e9b41 Mon Sep 17 00:00:00 2001 From: "Ithamar R. Adema" Date: Sat, 12 Jan 2008 23:48:52 +0000 Subject: [PATCH] Fix problem with CLOEXEC also being handled on fork(). For details on expected (BeOS) behaviour, see http://www.freelists.org/archives/openbeos/12-2001/msg00280.html git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23456 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/fs/vfs.cpp | 4 ++-- src/system/kernel/team.cpp | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/system/kernel/fs/vfs.cpp b/src/system/kernel/fs/vfs.cpp index 1f14040386..ff4446abf4 100644 --- a/src/system/kernel/fs/vfs.cpp +++ b/src/system/kernel/fs/vfs.cpp @@ -3501,7 +3501,7 @@ vfs_unlock_vnode_if_locked(struct file_descriptor *descriptor) /*! Closes all file descriptors of the specified I/O context that - don't have the O_CLOEXEC flag set. + have the O_CLOEXEC flag set. */ void vfs_exec_io_context(void *_context) @@ -3591,7 +3591,7 @@ vfs_new_io_context(void *_parentContext) for (i = 0; i < tableSize; i++) { struct file_descriptor *descriptor = parentContext->fds[i]; - if (descriptor != NULL && !fd_close_on_exec(parentContext, i)) { + if (descriptor != NULL) { context->fds[i] = descriptor; context->num_used_fds++; atomic_add(&descriptor->ref_count, 1); diff --git a/src/system/kernel/team.cpp b/src/system/kernel/team.cpp index 72735bf181..175eaff8d2 100644 --- a/src/system/kernel/team.cpp +++ b/src/system/kernel/team.cpp @@ -931,6 +931,9 @@ load_image_etc(int32 argCount, char * const *args, int32 envCount, goto err2; } + // remove any fds that have the CLOEXEC flag set (emulating BeOS behaviour) + vfs_exec_io_context(team->io_context); + // create an address space for this team status = vm_create_address_space(team->id, USER_BASE, USER_SIZE, false, &team->address_space);