Opened 7 years ago

Closed 7 years ago

#4274 closed bug (fixed)

Runtime should not set SIGPIPE to ignored for subprocesses

Reported by: phunge0 Owned by: simonmar
Priority: normal Milestone: 7.0.1
Component: Runtime System Version: 6.12.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect result at runtime Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


The GHC runtime ignores SIGPIPE by setting the signal to SIG_IGN. This means that any subprocesses (created via System.Process or otherwise) inwill also have their SIGPIPE handler set to SIG_IGN; I think this might be a bug. The Python runtime does the same thing, there's a good explanation of the drawbacks in:

IMHO the simplest fix is the patch below: simply avoid SIG_IGN, instead install a handler which does nothing. This way, an exec() restores the handler to SIG_DFL. I've included a testcase too.

Discussion link: Summarizing: Donn Cave expressed concern that installing a signal handler for SIGPIPE might not be transparent to the rest of the program, but since the runtime already uses signal handlers for SIGVTALRM, it shouldn't make matters any worse.

Attachments (1)

patch.2 (4.1 KB) - added by phunge0 7 years ago.
Bugfix and testcase patch

Download all attachments as: .zip

Change History (4)

Changed 7 years ago by phunge0

Attachment: patch.2 added

Bugfix and testcase patch

comment:1 Changed 7 years ago by simonmar

Component: CompilerRuntime System
Milestone: 7.0.1
Owner: set to simonmar

comment:2 Changed 7 years ago by simonmar

Status: newmerge

Done. I already had a patch for this in my tree, so I didn't use the supplied one. I did add the excellent test case from the patch though, thanks!

Sat Sep 25 12:35:48 PDT 2010  Simon Marlow <>
  * Use an empty signal handler for SIGPIPE instead of SIG_IGN
  This is so that the SIGPIPE handler gets reset to the default
  automatically on exec().

comment:3 Changed 7 years ago by igloo

Resolution: fixed
Status: mergeclosed


Note: See TracTickets for help on using tickets.