[libc-commits] [libc] [libc] Add 'x' and 'e' mode support to fopen() (PR #224207)
Pavel Labath via libc-commits
libc-commits at lists.llvm.org
Fri Sep 18 03:04:24 PDT 2026
================
@@ -119,6 +127,14 @@ ErrorOr<File *> openfile(const char *path, const char *mode) {
return file;
}
+static ErrorOr<int> set_close_on_exec(int fd) {
+ auto flags = linux_syscalls::fcntl(fd, F_GETFD);
+ if (!flags)
+ return Error(flags.error());
+ return linux_syscalls::fcntl(
+ fd, F_SETFD, reinterpret_cast<void *>(flags.value() | FD_CLOEXEC));
----------------
labath wrote:
That won't work because LinuxFileFlags is an open flag (O_CLOEXEC). This needs fcntl file flags (FD_CLOEXEC).
https://github.com/llvm/llvm-project/pull/224207
More information about the libc-commits
mailing list