diff --git a/fs/vfs/fs_fcntl.c b/fs/vfs/fs_fcntl.c index aaccd4ddce2..c6b929a4231 100644 --- a/fs/vfs/fs_fcntl.c +++ b/fs/vfs/fs_fcntl.c @@ -121,14 +121,12 @@ static int file_vfcntl(FAR struct file *filep, int cmd, va_list ap) if (oflags & FD_CLOEXEC) { - filep->f_oflags |= O_CLOEXEC; + ret = file_ioctl(filep, FIOCLEX, NULL); } else { - filep->f_oflags &= ~O_CLOEXEC; + ret = file_ioctl(filep, FIONCLEX, NULL); } - - ret = OK; } break; @@ -167,7 +165,6 @@ static int file_vfcntl(FAR struct file *filep, int cmd, va_list ap) oflags &= (FFCNTL & ~O_NONBLOCK); filep->f_oflags &= ~(FFCNTL & ~O_NONBLOCK); filep->f_oflags |= oflags; - ret = OK; } } break; diff --git a/fs/vfs/fs_ioctl.c b/fs/vfs/fs_ioctl.c index 796cbcff026..29c5ec7b100 100644 --- a/fs/vfs/fs_ioctl.c +++ b/fs/vfs/fs_ioctl.c @@ -95,13 +95,13 @@ int file_vioctl(FAR struct file *filep, int req, va_list ap) break; case FIOCLEX: - ret = file_fcntl(filep, F_SETFD, - file_fcntl(filep, F_GETFD) | FD_CLOEXEC); + filep->f_oflags |= O_CLOEXEC; + ret = OK; break; case FIONCLEX: - ret = file_fcntl(filep, F_SETFD, - file_fcntl(filep, F_GETFD) & ~FD_CLOEXEC); + filep->f_oflags &= ~O_CLOEXEC; + ret = OK; break; case FIOC_FILEPATH: diff --git a/include/fcntl.h b/include/fcntl.h index 2b1de821292..9cef7ed9e04 100644 --- a/include/fcntl.h +++ b/include/fcntl.h @@ -103,7 +103,7 @@ #define F_WRLCK 1 /* Take out a write lease */ #define F_UNLCK 2 /* Remove a lease */ -/* close-on-exec flag for F_GETRL and F_SETFL */ +/* close-on-exec flag for F_GETFD and F_SETFD */ #define FD_CLOEXEC 1