--- FAIL: TestCatGoodAndBadFile (0.01s)
    exec_test.go:430: expected test code; got "" (len 0)
FAIL
FAIL    os/exec 0.510s
ok      os/exec/internal/fdtest 0.012s
FAIL
go tool dist: Failed: exit status 1


Error: tests failed: dist test failed: {go_test:os os}: exit status 1

sendfile(3ext) on illumos seems to incur intermittent failures when the target file is the standard stream (stdout, stderr):

https://build.golang.org/log/bb20485d1d72074792215facb7b28ae661e6a6e0 https://build.golang.org/log/2c88f9652638bc186037196f95f84506c2e139c7 https://build.golang.org/log/4de2769138b79cd750b41ea950b148ffb118f6ef

Related CL: https://go.dev/cl/603098

/cc @ianlancetaylor @neild

Comment From: gopherbot

Change https://go.dev/cl/605355 mentions this issue: os: don't use sendfile(3ext) on illumos when target is standard stream

Comment From: gopherbot

Sorry, but I can't find a watchflakes script at the start of the issue description. See https://go.dev/wiki/Watchflakes for details.

watchflakes

Comment From: panjf2000

Looks like this flake didn't go away: https://build.golang.org/log/876e7c984d928194c55935da414eeb30e514473f

Comment From: panjf2000

/cc @ianlancetaylor

Comment From: panjf2000

It seems that stdout in exec_test.go on illumos turns out not to be a character device somehow. Maybe there is something like fd hijacking of stdout somehow? Despite sendfile() works for pipes on illumos in practice, it's not documented in the man pages, it instead only explicitly claims "The out_fd argument should be a file descriptor to a regular file opened for writing or to a connected AF_INET or AF_INET6 socket of SOCK_STREAM type", which is endorsed by the source code of the illumos kernel. Therefore, maybe we should be more conservative and only allow syscall.S_IFREG to avoid any uncanny cases.

Comment From: gopherbot

Change https://go.dev/cl/606135 mentions this issue: os: only employ sendfile(3ext) on illumos when target is regular file