On Unix-like platforms, with SIGPIPE signals being ignored, as in Ruby, writing to a broken pipe (a pipe whose reader process has since terminated) returns standard error code EPIPE.
However, it seems that in PowerShell - unlike in POSIX-like shells such as bash - the error code is not relayed to the writing process.
Steps to reproduce
Write 100,000 lines via Ruby, but cause the pipe to break via head -n 1 exiting after having received the 1st input line:
ruby -e '(1..1e5).each do |i| puts i end' | head -n 1
Expected behavior
1
-e:1:in `write': Broken pipe @ io_write - <STDOUT> (Errno::EPIPE)
from -e:1:in `puts'
from -e:1:in `puts'
from -e:1:in `block in <main>'
from -e:1:in `each'
from -e:1:in `<main>'
Actual behavior
That is, the Ruby code never saw the EPIPE standard error code that results from writing to a broken pipe while SIGPIPE signals are being ignored.
PowerShell Core v6.2.0-preview.2 on macOS 10.14.1
PowerShell Core v6.2.0-preview.2 on Ubuntu 18.04.1 LTS
On Unix-like platforms, with
SIGPIPEsignals being ignored, as in Ruby, writing to a broken pipe (a pipe whose reader process has since terminated) returns standard error codeEPIPE.However, it seems that in PowerShell - unlike in POSIX-like shells such as
bash- the error code is not relayed to the writing process.Steps to reproduce
Write 100,000 lines via Ruby, but cause the pipe to break via
head -n 1exiting after having received the 1st input line:Expected behavior
Actual behavior
That is, the Ruby code never saw the
EPIPEstandard error code that results from writing to a broken pipe whileSIGPIPEsignals are being ignored.