Commit 129d3e274d

daurnimator <quae@daurnimator.com>
2020-08-23 18:28:31
std: use O_NOCTTY flag
1 parent 23a81b4
Changed files (2)
lib
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
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)