Fix handling of SIGPIPE
Fixes #41