Go: syscall: add SysProcAttr.NoInheritHandles on Windows

Created on 20 Oct 2020  路  10Comments  路  Source: golang/go

This is a proposal for the API change in the existing CL https://golang.org/cl/261917.

The proposal is to add a new field DontInheritHandles to syscall.SysProcAttr on Windows. Setting this field will cause handles to not be inherited when creating a child process.

The negative field name is unfortunate but it's hard to see how to avoid it while preserving the desired semantics of the zero value of SysProcAttr.

OS-Windows Proposal Proposal-Accepted Proposal-FinalCommentPeriod

All 10 comments

A bit of background to this CL

Currently, CreateProcess/CreateProcessAsUser is called with bInheritHandles set to true.

In my use case on Windows, I have a service running in session 0 that spawns a process in another session.

As per the documentation here:
https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessa

"Terminal Services: You cannot inherit handles across sessions. Additionally, if this parameter is TRUE, you must create the process in the same session as the caller."

We don't have any fields beginning with Dont, which is a bit difficult because of the missing apostrophe, among other things.
But we do have a bunch of fields and other names that begin with the word "No".
So maybe NoInheritHandles would be better.
(It can't be InheritHandles because we want inherit to be the default, but the default will be the zero value for this struct field.)

With NoInheritHandles, this seems fine to me.

Does anyone object to this change?

Thanks @rsc

I've updated the CL to rename DontInheritHandles->NoInheritHandles

Change https://golang.org/cl/261917 mentions this issue: syscall: expose bInheritHandles of CreateProcess

DontInheritHandles->NoInheritHandles SGTM.

Thank you.

Alex

Based on the discussion above, this seems like a likely accept.

No change in consensus, so accepted.

No change in consensus, so accepted.

@rsc does that mean we can submit

https://go-review.googlesource.com/c/go/+/261917/

?

Thank you.

Alex

Yes.

Was this page helpful?
0 / 5 - 0 ratings