diff --git a/lib/std/fs.zig b/lib/std/fs.zig index d9c949ef336a79ba1b40a5a4b922be124240a81d..21a00eeb1da7ffd755933b3e7346bbb5800e6b85 100644 --- a/lib/std/fs.zig +++ b/lib/std/fs.zig @@ -704,6 +704,9 @@ pub const Dir = struct { if (@hasDecl(os, "O_LARGEFILE")) { os_flags |= os.O_LARGEFILE; } + if (!flags.allow_ctty) { + os_flags |= os.O_NOCTTY; + } os_flags |= if (flags.write and flags.read) @as(u32, os.O_RDWR) else if (flags.write) diff --git a/lib/std/fs/file.zig b/lib/std/fs/file.zig index 3e22528ea991b0021819f43e56ba700b73208ca9..6fb2385a852d323f10c4a707c30705a1f7290e9e 100644 --- a/lib/std/fs/file.zig +++ b/lib/std/fs/file.zig @@ -101,6 +101,10 @@ pub const File = struct { /// if `std.io.is_async`. It allows the use of `nosuspend` when calling functions /// related to opening the file, reading, writing, and locking. intended_io_mode: io.ModeOverride = io.default_mode, + + /// Set this to allow the opened file to automatically become the + /// controlling TTY for the current process. + allow_ctty: bool = false, }; /// TODO https://github.com/ziglang/zig/issues/3802