@@ -235,12 +235,13 @@ type ProcAttr struct {
235235}
236236
237237type 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
244245}
245246
246247var zeroProcAttr ProcAttr
@@ -341,9 +342,9 @@ func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid int, handle
341342
342343 flags := sys .CreationFlags | CREATE_UNICODE_ENVIRONMENT
343344 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 )
345346 } 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 )
347348 }
348349 if err != nil {
349350 return 0 , 0 , err
0 commit comments