@@ -821,7 +821,7 @@ pub const ChildProcess = struct {
821
821
fn spawnWindows (self : * ChildProcess ) SpawnError ! void {
822
822
const saAttr = windows.SECURITY_ATTRIBUTES {
823
823
.nLength = @sizeOf (windows .SECURITY_ATTRIBUTES ),
824
- .bInheritHandle = windows .TRUE ,
824
+ .bInheritHandle = windows .FALSE ,
825
825
.lpSecurityDescriptor = null ,
826
826
};
827
827
@@ -883,6 +883,11 @@ pub const ChildProcess = struct {
883
883
& tmp_hChildStd_Wr ,
884
884
& saAttr ,
885
885
);
886
+ errdefer {
887
+ os .close (tmp_hChildStd_Rd );
888
+ os .close (tmp_hChildStd_Wr );
889
+ }
890
+ try windows .SetHandleInformation (tmp_hChildStd_Wr , windows .HANDLE_FLAG_INHERIT , 1 );
886
891
g_hChildStd_OUT_Rd = tmp_hChildStd_Rd ;
887
892
g_hChildStd_OUT_Wr = tmp_hChildStd_Wr ;
888
893
},
@@ -909,6 +914,11 @@ pub const ChildProcess = struct {
909
914
& tmp_hChildStd_Wr ,
910
915
& saAttr ,
911
916
);
917
+ errdefer {
918
+ os .close (tmp_hChildStd_Rd );
919
+ os .close (tmp_hChildStd_Wr );
920
+ }
921
+ try windows .SetHandleInformation (tmp_hChildStd_Wr , windows .HANDLE_FLAG_INHERIT , 1 );
912
922
g_hChildStd_ERR_Rd = tmp_hChildStd_Rd ;
913
923
g_hChildStd_ERR_Wr = tmp_hChildStd_Wr ;
914
924
},
@@ -1495,7 +1505,7 @@ fn windowsMakePipeIn(rd: *?windows.HANDLE, wr: *?windows.HANDLE, sattr: *const w
1495
1505
var wr_h : windows.HANDLE = undefined ;
1496
1506
try windows .CreatePipe (& rd_h , & wr_h , sattr );
1497
1507
errdefer windowsDestroyPipe (rd_h , wr_h );
1498
- try windows .SetHandleInformation (wr_h , windows .HANDLE_FLAG_INHERIT , 0 );
1508
+ try windows .SetHandleInformation (rd_h , windows .HANDLE_FLAG_INHERIT , 1 );
1499
1509
rd .* = rd_h ;
1500
1510
wr .* = wr_h ;
1501
1511
}
@@ -1504,6 +1514,8 @@ var pipe_name_counter = std.atomic.Atomic(u32).init(1);
1504
1514
1505
1515
/// To enable/disable inheritance parent and child process, use
1506
1516
/// os.enableInheritance() and os.disableInheritance() on the handle.
1517
+ /// convention: sattr uses bInheritHandle = windows.FALSE and only used pipe end
1518
+ /// is enabled.
1507
1519
pub fn windowsMakeAsyncPipe (
1508
1520
rd : * windows.HANDLE ,
1509
1521
wr : * windows.HANDLE ,
@@ -1561,7 +1573,6 @@ pub fn windowsMakeAsyncPipe(
1561
1573
else = > | err | return windows .unexpectedError (err ),
1562
1574
}
1563
1575
}
1564
- errdefer os .close (write_handle );
1565
1576
1566
1577
rd .* = read_handle ;
1567
1578
wr .* = write_handle ;
0 commit comments