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);