-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proposal: exec: add (*Cmd).ExtraInPipe and ExtraOutPipe #37094
Comments
I'm not sure there would be enough users/uses of this to warrant complicating the API. |
@bradfitz Ok thanks. Close or wait for more comments or alternatives? I did a "execextra" package with a Cmd type that embeds an exec.Cmd and wraps some of the methods. Seems to work quite well. Might add a link to it here if i feel happy with it. |
Based on the discussion above, this seems like a likely decline. |
No change in consensus, so declined. |
Add convenience methods for using
Cmd.ExtraFiles
that returnsio.ReadCloser
andio.WriteCloser
and also deal with file descriptor numbers in the child process. Similar to existingStdinPipe
andStdoutPipe
methods.An implementation in the exec package could look something like this:
Both are very similar to how
StdinPipe
andStdoutPipe
works but also returns the fd number that will be available in the forked child process.Some design note and issues:
If you want to use
exec.Command()
and pass an extra pipe fd number as argument you will need to modifyCmd.Args
field afterwards.What happens if
ExtraInPipe
orExtraOutPipe
is used butCmd.Start()
is never called? enough withos.Pipe()
newFile close finalizer for cleanup? user should close them? same issue forStdinPipe
andStdoutPipe
i guess?Might be unintuitive that the public ExtraFiles field gets modified.
Uses
uintptr
for fd number. Same asFile.Fd()
.Will not work on Windows. Same as for
Cmd.ExtraFiles
.Related to #15460
The text was updated successfully, but these errors were encountered: