@@ -235,12 +235,13 @@ type ProcAttr struct {
235
235
}
236
236
237
237
type SysProcAttr struct {
238
- HideWindow bool
239
- CmdLine string // used if non-empty, else the windows command line is built by escaping the arguments passed to StartProcess
240
- CreationFlags uint32
241
- Token Token // if set, runs new process in the security context represented by the token
242
- ProcessAttributes * SecurityAttributes // if set, applies these security attributes as the descriptor for the new process
243
- ThreadAttributes * SecurityAttributes // if set, applies these security attributes as the descriptor for the main thread of the new process
238
+ HideWindow bool
239
+ CmdLine string // used if non-empty, else the windows command line is built by escaping the arguments passed to StartProcess
240
+ CreationFlags uint32
241
+ Token Token // if set, runs new process in the security context represented by the token
242
+ ProcessAttributes * SecurityAttributes // if set, applies these security attributes as the descriptor for the new process
243
+ ThreadAttributes * SecurityAttributes // if set, applies these security attributes as the descriptor for the main thread of the new process
244
+ DontInheritHandles bool
244
245
}
245
246
246
247
var zeroProcAttr ProcAttr
@@ -341,9 +342,9 @@ func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid int, handle
341
342
342
343
flags := sys .CreationFlags | CREATE_UNICODE_ENVIRONMENT
343
344
if sys .Token != 0 {
344
- err = CreateProcessAsUser (sys .Token , argv0p , argvp , sys .ProcessAttributes , sys .ThreadAttributes , true , flags , createEnvBlock (attr .Env ), dirp , si , pi )
345
+ err = CreateProcessAsUser (sys .Token , argv0p , argvp , sys .ProcessAttributes , sys .ThreadAttributes , ! sys . DontInheritHandles , flags , createEnvBlock (attr .Env ), dirp , si , pi )
345
346
} else {
346
- err = CreateProcess (argv0p , argvp , sys .ProcessAttributes , sys .ThreadAttributes , true , flags , createEnvBlock (attr .Env ), dirp , si , pi )
347
+ err = CreateProcess (argv0p , argvp , sys .ProcessAttributes , sys .ThreadAttributes , ! sys . DontInheritHandles , flags , createEnvBlock (attr .Env ), dirp , si , pi )
347
348
}
348
349
if err != nil {
349
350
return 0 , 0 , err
0 commit comments