Bug#573779: Programs run due by pipe transport get SIGPIPE set to IGN

Ian Jackson ijackson at chiark.greenend.org.uk
Sat Mar 13 20:51:27 UTC 2010


Package: exim4
Version: 4.63-17

I set up a test program, piping into the following perl script:

  $ cat junk/t.pl 
  #!/usr/bin/perl
  print STDERR "Signal handling for SIGPIPE: $SIG{PIPE}.\n";
  die;
  $

When I tested this by putting 
  |/home/ian/junk/t.pl
in .forward and sending an email, the expected bounce contained the
following text:

  The following text was generated during the delivery attempt:

  ------ pipe to |/home/ian/junk/t.pl
	 generated by ian at liberator.relativity.greenend.org.uk ------

  Signal handling for SIGPIPE: IGNORE.
  Died at /home/ian/junk/t.pl line 3.

On UN*X all programs are entitled to assume that they inherit SIGPIPE
(and most other signals) set to SIG_DFL.  Programs with careful error
handling can fail when SIGPIPE is set to SIG_IGN, because it causes
programs such as "cat" to do this:

  $ sh -xc 'trap "" PIPE; (sleep 1; echo hi) | cat | true;
  echo ${PIPESTATUS[*]}'
  + trap '' PIPE
  + sleep 1
  + cat
  + true
  + echo hi
  cat: write error: Broken pipe
  + echo 0 1 0
  0 1 0
  $ 

Rather than this:

  $ sh -xc '(sleep 1; echo hi) | cat | true; echo
  ${PIPESTATUS[*]}'
  + sleep 1
  + cat
  + true
  + echo hi
  + echo 0 141 0
  0 141 0
  $ 

Ian.





More information about the Pkg-exim4-maintainers mailing list