golang/go

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

Open

#37.857 aperta il 14 mar 2020

Vedi su GitHub
 (6 commenti) (0 reazioni) (0 assegnatari)Go (19.008 fork)batch import
DocumentationNeedsFixhelp wanted

Metriche repository

Star
 (133.883 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

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.

Guida contributor