[libc-commits] [libc] [libc] Add 'x' and 'e' mode support to fopen() (PR #224207)

Michael Jones via libc-commits libc-commits at lists.llvm.org
Thu Sep 17 09:53:30 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));
----------------
michaelrj-google wrote:

this should use `LinuxFileFlags::CLOSE_ON_EXEC` for consistency.

https://github.com/llvm/llvm-project/pull/224207


More information about the libc-commits mailing list