-
Notifications
You must be signed in to change notification settings - Fork 18k
os/exec: status of FDs >= len(cmd.ExtraFiles)+3 is undocumented #37857
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
Comments
The status of files that are not listed in |
I'm talking about FDs >= len(cmd.ExtraFiles)+3: I demonstrated a case in which the parent has 2 of them (from shell redirection, hence FD_CLOEXEC unset), and one of them is closed in the child but the other is not. Have you actually read my test case? Here is another example: cmd := exec.Command("child-cmd")
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stderr // swapping stdout and stderr
cmd.Stderr = os.Stdout
cmd.Start() Invocation: Without swapping: cmd := exec.Command("child-cmd")
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Start() Same invocation: |
Sorry, you're right; I was very unclear. When I said "files", I mean But upon reflection even that is not quite right, since if you do use shell redirection and then use |
@ianlancetaylor, sorry, you are still missing my point. I would expect parent FDs >= len(cmd.ExtraFiles)+3 to be never inherited if they have But if they have Have you read the example in my previous message? Can you explain why the effect on FD 4 is different between the two programs? |
Hmmm, I still haven't looked very closely at this, but that makes me think that this is just a bug. Perhaps the code in syscall should |
What version of Go are you using (
go version
)?go version go1.14 linux/amd64
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOOS="linux"
What did you do?
Invocation:
$ parent-cmd 0<a 1>b 2>c 3>d 4>e 5>f
What did you expect to see?
File descriptors 4 and 5 (>= len(cmd.ExtraFiles)+3) to be either both inherited or none, and the behavior to be documented.
What did you see instead?
File descriptor 4 is inherited, but 5 is not. The doc doesn't say anything about
FDs >= len(cmd.ExtraFiles)+3 in the child process.
The text was updated successfully, but these errors were encountered: