diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-01-16 15:03:25 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-16 15:03:25 -0800 |
| commit | a338c279f82bfeb68e37b40cd4fc59557336b6ce (patch) | |
| tree | e4a99e0758638e49f96a16aed15f6280ecb6676b /lib/std/child_process.zig | |
| parent | 1ce12db5c8b8d0369d431cbfa90fa6dc4c0141ce (diff) | |
| parent | 194ed308259e49af3f4725659e22ccd7457404e0 (diff) | |
| download | zig-a338c279f82bfeb68e37b40cd4fc59557336b6ce.tar.gz zig-a338c279f82bfeb68e37b40cd4fc59557336b6ce.zip | |
Merge pull request #15565 from xEgoist/spawnWindows
child_process: Add write and inheritable access to the null handle
Diffstat (limited to 'lib/std/child_process.zig')
| -rw-r--r-- | lib/std/child_process.zig | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/std/child_process.zig b/lib/std/child_process.zig index 444adebbdc..0a0c06ff89 100644 --- a/lib/std/child_process.zig +++ b/lib/std/child_process.zig @@ -650,7 +650,7 @@ pub const ChildProcess = struct { } fn spawnWindows(self: *ChildProcess) SpawnError!void { - const saAttr = windows.SECURITY_ATTRIBUTES{ + var saAttr = windows.SECURITY_ATTRIBUTES{ .nLength = @sizeOf(windows.SECURITY_ATTRIBUTES), .bInheritHandle = windows.TRUE, .lpSecurityDescriptor = null, @@ -661,8 +661,9 @@ 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, + .sa = &saAttr, .creation = windows.OPEN_EXISTING, .io_mode = .blocking, }) catch |err| switch (err) { @@ -680,9 +681,6 @@ pub const ChildProcess = struct { defer { if (any_ignore) os.close(nul_handle); } - if (any_ignore) { - try windows.SetHandleInformation(nul_handle, windows.HANDLE_FLAG_INHERIT, 0); - } var g_hChildStd_IN_Rd: ?windows.HANDLE = null; var g_hChildStd_IN_Wr: ?windows.HANDLE = null; |
