mirror of
https://github.com/golang/go
synced 2024-11-20 06:44:40 -07:00
syscall: fix duplicate fd bug for Plan 9
This change comes from CL 5536043, created by Andrey Mirtchovski. His description follows: "The plan9 exec child handler does not manage dup-ed fds from the parent correctly: when a dup-ed file descriptor appears in the child's fd list it is closed when first encountered and then subsequent attempt to dup it later in Pass 2 fails, resulting in 'fork/exec: fd out of range or not open'." R=golang-dev, rminnich, ality CC=golang-dev, mirtchovski, rsc https://golang.org/cl/6009046
This commit is contained in:
parent
bd7c4aee96
commit
4cf577edf9
@ -287,8 +287,14 @@ func forkAndExecInChild(argv0 *byte, argv []*byte, envv []envItem, dir *byte, at
|
|||||||
if int(r1) == -1 {
|
if int(r1) == -1 {
|
||||||
goto childerror
|
goto childerror
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pass 3: close fds that were dup-ed
|
||||||
|
for i = 0; i < len(fd); i++ {
|
||||||
|
if fd[i] >= 0 && fd[i] != int(i) {
|
||||||
RawSyscall(SYS_CLOSE, uintptr(fd[i]), 0, 0)
|
RawSyscall(SYS_CLOSE, uintptr(fd[i]), 0, 0)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Time to exec.
|
// Time to exec.
|
||||||
r1, _, _ = RawSyscall(SYS_EXEC,
|
r1, _, _ = RawSyscall(SYS_EXEC,
|
||||||
|
Loading…
Reference in New Issue
Block a user