std: use O_NOCTTY flag

This commit is contained in:
daurnimator 2020-08-24 02:28:31 +10:00
parent 23a81b4396
commit 129d3e274d
No known key found for this signature in database
GPG Key ID: 45B429A8F9D9D22A
2 changed files with 7 additions and 0 deletions

View File

@ -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)

View File

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