Skip to content

Commit

Permalink
os/exec: skip poll descriptors when checking for open descriptors
Browse files Browse the repository at this point in the history
It turns out that there is a path that initializes netpoll and opens
file descriptors before running the os/exec init function: on some
systems, the uses of NewFile when setting os.Stdin and friends can
initialize netpoll which can open file descriptors. This in itself
is not a problem, but when we check whether the new files are open
using os.NewFile, a side-effect is to put them into non-blocking mode.
This can then break future uses of netpoll.

Updates #35469
Fixes #35566

Change-Id: I1b2e2c943695d1c2d29496b050abbce9ee710a00
Reviewed-on: https://go-review.googlesource.com/c/go/+/207078
Reviewed-by: Bryan C. Mills <bcmills@google.com>
  • Loading branch information
ianlancetaylor committed Nov 13, 2019
1 parent 49e05d4 commit 718f553
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/os/exec/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ func init() {
return
}
for fd := uintptr(3); fd <= 100; fd++ {
if poll.IsPollDescriptor(fd) {
continue
}
// We have no good portable way to check whether an FD is open.
// We use NewFile to create a *os.File, which lets us
// know whether it is open, but then we have to cope with
Expand Down

0 comments on commit 718f553

Please sign in to comment.