CLOEXEC
is set right when the pipe is opened, so you have to set $^F
before running pipe
. If you switch that order, it works fine for me, even without using fcntl
.
Also, if you want to set it using fcntl
, you need to use F_SETFD
, not F_SETFL