diff options
| author | xEgoist <egoist@egoistic.dev> | 2023-05-02 13:36:48 -0500 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2024-01-16 01:25:14 -0800 |
| commit | 41bf816fa6dd6fde0264db885c2f00757aba74b0 (patch) | |
| tree | 5aaa7a0fa8e8849db31f4f2f065e5f6d06581ff3 /lib/std/child_process.zig | |
| parent | 7116b02210bcae7bafac9017a7e47a14b52eafc2 (diff) | |
| download | zig-41bf816fa6dd6fde0264db885c2f00757aba74b0.tar.gz zig-41bf816fa6dd6fde0264db885c2f00757aba74b0.zip | |
child_process: Add write access to the null handle
This commit allows write access to the `\\Device\\Null` Handle.
Without a write access, it's not possible for the child process to write
SdOut to Null. As a requirement `SetHandleInformation` was also changed
to mark the handle as iheritable (by adding it to Flags) by the spawned process.
This allows the child to access the NUL device that was opened.
This also makes the Windows part to behave similarly to `spawnPosix`.
Diffstat (limited to 'lib/std/child_process.zig')
| -rw-r--r-- | lib/std/child_process.zig | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/std/child_process.zig b/lib/std/child_process.zig index 444adebbdc..4be8b1cd83 100644 --- a/lib/std/child_process.zig +++ b/lib/std/child_process.zig @@ -661,8 +661,8 @@ pub const ChildProcess = struct { const nul_handle = if (any_ignore) // "\Device\Null" or "\??\NUL" windows.OpenFile(&[_]u16{ '\\', 'D', 'e', 'v', 'i', 'c', 'e', '\\', 'N', 'u', 'l', 'l' }, .{ - .access_mask = windows.GENERIC_READ | windows.SYNCHRONIZE, - .share_access = windows.FILE_SHARE_READ, + .access_mask = windows.GENERIC_READ | windows.GENERIC_WRITE | windows.SYNCHRONIZE, + .share_access = windows.FILE_SHARE_READ | windows.FILE_SHARE_WRITE, .creation = windows.OPEN_EXISTING, .io_mode = .blocking, }) catch |err| switch (err) { @@ -681,7 +681,7 @@ pub const ChildProcess = struct { if (any_ignore) os.close(nul_handle); } if (any_ignore) { - try windows.SetHandleInformation(nul_handle, windows.HANDLE_FLAG_INHERIT, 0); + try windows.SetHandleInformation(nul_handle, windows.HANDLE_FLAG_INHERIT, windows.HANDLE_FLAG_INHERIT); } var g_hChildStd_IN_Rd: ?windows.HANDLE = null; |
