@@ -24,6 +24,7 @@ const is_windows = builtin.os == Os.windows;
2424pub const ChildProcess = struct {
2525 pub pid : if (is_windows ) void else i32 ,
2626 pub handle : if (is_windows ) windows .HANDLE else void ,
27+ pub thread_handle : if (is_windows ) windows .HANDLE else void ,
2728
2829 pub allocator : & mem.Allocator ,
2930
@@ -82,6 +83,7 @@ pub const ChildProcess = struct {
8283 .argv = argv ,
8384 .pid = undefined ,
8485 .handle = undefined ,
86+ .thread_handle = undefined ,
8587 .err_pipe = undefined ,
8688 .llnode = undefined ,
8789 .term = null ,
@@ -210,14 +212,15 @@ pub const ChildProcess = struct {
210212
211213 self .term = (% Term )({
212214 var exit_code : windows.DWORD = undefined ;
213- if (! windows .GetExitCodeProcess (self .handle , & exit_code )) {
215+ if (windows .GetExitCodeProcess (self .handle , & exit_code ) == 0 ) {
214216 Term.Unknown {0 }
215217 } else {
216218 Term.Exited {@bitCast (i32 , exit_code )}
217219 }
218220 });
219221
220222 os .windowsClose (self .handle );
223+ os .windowsClose (self .thread_handle );
221224 self .cleanupStreams ();
222225 return result ;
223226 }
@@ -430,10 +433,11 @@ pub const ChildProcess = struct {
430433 }
431434
432435 fn spawnWindows (self : & ChildProcess ) - > % void {
433- var saAttr : windows.SECURITY_ATTRIBUTES = undefined ;
434- saAttr .nLength = @sizeOf (windows .SECURITY_ATTRIBUTES );
435- saAttr .bInheritHandle = true ;
436- saAttr .lpSecurityDescriptor = null ;
436+ var saAttr = windows.SECURITY_ATTRIBUTES {
437+ .nLength = @sizeOf (windows .SECURITY_ATTRIBUTES ),
438+ .bInheritHandle = windows .TRUE ,
439+ .lpSecurityDescriptor = null ,
440+ };
437441
438442 const any_ignore = (self .stdin_behavior == StdIo .Ignore or
439443 self .stdout_behavior == StdIo .Ignore or
@@ -571,9 +575,9 @@ pub const ChildProcess = struct {
571575 defer if (maybe_envp_buf ) | envp_buf | self .allocator .free (envp_buf );
572576 const envp_ptr = if (maybe_envp_buf ) | envp_buf | envp_buf .ptr else null ;
573577
574- if (! windows .CreateProcessA (app_name .ptr , cmd_line .ptr , null , null , true , 0 ,
578+ if (windows .CreateProcessA (app_name .ptr , cmd_line .ptr , null , null , windows . TRUE , 0 ,
575579 @ptrCast (? & c_void , envp_ptr ),
576- cwd_ptr , & siStartInfo , & piProcInfo ))
580+ cwd_ptr , & siStartInfo , & piProcInfo ) == windows . FALSE )
577581 {
578582 const err = windows .GetLastError ();
579583 return switch (err ) {
@@ -582,7 +586,6 @@ pub const ChildProcess = struct {
582586 else = > error .Unexpected ,
583587 };
584588 }
585- os .windowsClose (piProcInfo .hThread );
586589
587590 if (stdin_ptr ) | outstream | {
588591 * outstream = io.OutStream {
@@ -609,6 +612,7 @@ pub const ChildProcess = struct {
609612 }
610613
611614 self .handle = piProcInfo .hProcess ;
615+ self .thread_handle = piProcInfo .hThread ;
612616 self .term = null ;
613617 self .stdin = stdin_ptr ;
614618 self .stdout = stdout_ptr ;
@@ -672,7 +676,7 @@ fn windowsDestroyPipe(rd: ?windows.HANDLE, wr: ?windows.HANDLE) {
672676}
673677
674678fn windowsMakePipe (rd : & windows.HANDLE , wr : & windows.HANDLE , sattr : & windows.SECURITY_ATTRIBUTES ) - > % void {
675- if (! windows .CreatePipe (rd , wr , sattr , 0 )) {
679+ if (windows .CreatePipe (rd , wr , sattr , 0 ) == 0 ) {
676680 const err = windows .GetLastError ();
677681 return switch (err ) {
678682 else = > error .Unexpected ,
@@ -681,7 +685,7 @@ fn windowsMakePipe(rd: &windows.HANDLE, wr: &windows.HANDLE, sattr: &windows.SEC
681685}
682686
683687fn windowsSetHandleInfo (h : windows.HANDLE , mask : windows.DWORD , flags : windows.DWORD ) - > % void {
684- if (! windows .SetHandleInformation (h , mask , flags )) {
688+ if (windows .SetHandleInformation (h , mask , flags ) == 0 ) {
685689 const err = windows .GetLastError ();
686690 return switch (err ) {
687691 else = > error .Unexpected ,
0 commit comments