From 24d31878d2b2dc614c31a0f23e6255d0e233c8d8 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Wed, 3 Sep 2008 01:06:03 +0200 Subject: [PATCH] Restore the default SIGPIPE handler before exiting. --- src/tee.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/src/tee.c b/src/tee.c index 42eb689..34c3891 100644 --- a/src/tee.c +++ b/src/tee.c @@ -133,6 +133,13 @@ main (int argc, char **argv) POSIX requires that it work when given no arguments. */ ok = tee_files (argc - optind, (const char **) &argv[optind]); + + /* Restore the default SIGPIPE signal handling before exiting. From this + point on, we prefer to get a SIGPIPE signal to an EPIPE error, since + close_stdout interprets EPIPE as a failure condition. */ + if (ignore_sigpipe) + signal (SIGPIPE, SIG_DFL); + if (close (STDIN_FILENO) != 0) error (EXIT_FAILURE, errno, _("standard input")); -- 1.5.6.3