zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 129d3e274dbc3e11a30e3d54c5da7a944ddcf4f0 (tree)
parent 23a81b439638fee89054ad749f0348ab7d107619
Author: daurnimator <quae@daurnimator.com>
Date:   Mon, 24 Aug 2020 02:28:31 +1000

std: use O_NOCTTY flag

Diffstat:
Mlib/std/fs.zig | 3+++
Mlib/std/fs/file.zig | 4++++
2 files changed, 7 insertions(+), 0 deletions(-)

diff --git 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 @@ -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