golang/go

os/exec: status of FDs >= len(cmd.ExtraFiles)+3 is undocumented

Open

#37,857 创建于 2020年3月14日

在 GitHub 查看
 (6 评论) (0 反应) (0 负责人)Go (19,008 fork)batch import
DocumentationNeedsFixhelp wanted

仓库指标

Star
 (133,883 star)
PR 合并指标
 (30 天内没有已合并 PR)

描述

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

cmd := exec.Command("child-cmd")
cmd.ExtraFiles = []*os.File{os.Stderr}
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Start() // in child-cmd: 0=a 1=b 2=c 3=c 4=e 5=closed!

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.

贡献者指南