SIGPIPE in the GHC runtime

Donn Cave donn at avvanta.com
Wed Aug 18 19:06:57 EDT 2010


Quoth Brian Bloniarz <brian.bloniarz at gmail.com>,
...
> I just tested linux in this scenario, it gives EPIPE as I'd expect.
> Linux's SA_RESTART has been reliable in my limited experience. Do
> you have an OpenSolaris install to test by any chance? The code is
> below.

No, sorry!  But I don't doubt that with the right compile options
and so forth, that test would work fine on OpenSolaris.  Without
knowing what really caused the problem I mentioned, I can't guess
how to duplicate the problem or test for it.  (Cf. "hGetContents:
resource exhausted", Haskell Cafe, lally.singh at gmail.com.)  I know
that's rather unhelpful.  I hate unnecessary signals.

On the bright side, your approach sure has some appealing points,
compared to tracking down every place an execve(2) might happen.
The only solution of greater elegance would be for GHC to simply
leave SIGPIPE the way it was.

A less elegant variaton on that would be to block SIGPIPE, instead
of ignoring it.  I don't have a great deal of practical experience
with that, nor have I looked at how it would fit with GHC runtime
code, but execve(2) does reset the signal mask, so it would have
the inheritance properties you want.  I tried sigprocmask() and
pthread_sigmask(); either worked the same for me, but something
like this needs more testing.

	Donn Cave, donn at avvanta.com


More information about the Glasgow-haskell-users mailing list