Opened 9 years ago

Closed 7 years ago

Last modified 4 years ago

#12187 closed enhancement (fixed)

F_DUPFD_CLOEXEC missing

Reported by: haiqu Owned by: nobody
Priority: low Milestone: R1/beta2
Component: System/POSIX Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description

fcntl.h should define F_DUPFD_CLOEXEC, see Posix 2008

Change History (5)

comment:1 by waddlesplash, 9 years ago

Component: - GeneralSystem/POSIX
Milestone: UnscheduledR2
Priority: normallow
Type: taskenhancement

comment:2 by korli, 7 years ago

Proposed patch:

diff --git a/headers/posix/fcntl.h b/headers/posix/fcntl.h
index ad762f5..7e0805f 100644
--- a/headers/posix/fcntl.h
+++ b/headers/posix/fcntl.h
@@ -20,6 +20,7 @@
 #define F_GETLK         0x0020         /* get locking information */
 #define F_SETLK         0x0080         /* set locking information */
 #define F_SETLKW        0x0100         /* as above, but waits if blocked */
+#define        F_DUPFD_CLOEXEC 0x0200          /* duplicate fd with close on exec set */
 
 /* advisory locking types */
 #define F_RDLCK         0x0040         /* read or shared lock */
diff --git a/src/system/kernel/fs/vfs.cpp b/src/system/kernel/fs/vfs.cpp
index ea47773..35b7d90 100644
--- a/src/system/kernel/fs/vfs.cpp
+++ b/src/system/kernel/fs/vfs.cpp
@@ -6147,13 +6147,14 @@ common_fcntl(int fd, int op, size_t argument, bool kernel)
                        break;
 
                case F_DUPFD:
+               case F_DUPFD_CLOEXEC:
                {
                        struct io_context* context = get_current_io_context(kernel);
 
                        status = new_fd_etc(context, descriptor, (int)argument);
                        if (status >= 0) {
                                mutex_lock(&context->io_mutex);
-                               fd_set_close_on_exec(context, fd, false);
+                               fd_set_close_on_exec(context, fd, op == F_DUPFD_CLOEXEC);
                                mutex_unlock(&context->io_mutex);
 
                                atomic_add(&descriptor->ref_count, 1);

comment:3 by korli, 7 years ago

Resolution: fixed
Status: newclosed

Applied in hrev51372.

comment:4 by pulkomandy, 5 years ago

Milestone: R2R1

comment:5 by nielx, 4 years ago

Milestone: R1R1/beta2

Assign tickets with status=closed and resolution=fixed within the R1/beta2 development window to the R1/beta2 Milestone

Note: See TracTickets for help on using tickets.