I just realized that what we do here is incorrect even on Linux. In
src/Darcs/Util/SignalHandler.hs it says
| s == sigPIPE = exitWith $ ExitFailure 1
And indeed, when I run `darcs log` and then hit 'q' to terminate the
pager, the exit code is 1, which is wrong. I think that, at least when
we pipe our output through a pager, we should ignore SIGPIPE and handle
(i.e catch and ignore) the EPIPE error when the write fails. Looking
closer at the code in src/Darcs/UI/External.hs, I see that there *is*
code to handle EPIPE in the function ortryrunning, which among other
things also handles the ResourceVanished exception ... which (if I
understand things correctly) should not be raised because we do have a
handler for SIGPIPE.
The signal handling code is very old and quite messy, so I may have
overlooked something. And it doesn't explain why the behavior differs
between Linux and OpenBSD. |