From 963e8544f4c558dbe78b47d5b4ba3773ec54f11c Mon Sep 17 00:00:00 2001 From: Laytan Laats Date: Fri, 23 Aug 2024 20:24:40 +0200 Subject: [PATCH] os2: CLOEXEC the fds from `pipe` for posix implementation --- core/os/os2/pipe_posix.odin | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/os/os2/pipe_posix.odin b/core/os/os2/pipe_posix.odin index 62d6fc9fb..13c1f8aec 100644 --- a/core/os/os2/pipe_posix.odin +++ b/core/os/os2/pipe_posix.odin @@ -12,6 +12,15 @@ _pipe :: proc() -> (r, w: ^File, err: Error) { return } + if posix.fcntl(fds[0], .SETFD, i32(posix.FD_CLOEXEC)) == -1 { + err = _get_platform_error() + return + } + if posix.fcntl(fds[1], .SETFD, i32(posix.FD_CLOEXEC)) == -1 { + err = _get_platform_error() + return + } + r = __new_file(fds[0]) ri := (^File_Impl)(r.impl)