summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--Src/exec.c2
-rw-r--r--Src/init.c1
-rw-r--r--Src/signals.c13
4 files changed, 21 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index b89f90015..3cccf62ec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-09-28  Barton E. Schaefer  <schaefer@zsh.org>
+
+	* 33268: Src/exec.c, Src/init.c, Src/signals.c: interactive shells
+	treat SIGPIPE like SIGHUP if and only if SHTTY is disconnected
+
 2014-09-27  Barton E. Schaefer  <schaefer@zsh.org>
 
 	* 33256: Src/prompt.c: fix prompttrunc() counting of %{ %} spans
diff --git a/Src/exec.c b/Src/exec.c
index fb2739acc..fbd309580 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -1005,6 +1005,8 @@ entersubsh(int flags)
 	signal_default(SIGTERM);
 	if (!(sigtrapped[SIGINT] & ZSIG_IGNORED))
 	    signal_default(SIGINT);
+	if (!(sigtrapped[SIGPIPE]))
+	    signal_default(SIGPIPE);
     }
     if (!(sigtrapped[SIGQUIT] & ZSIG_IGNORED))
 	signal_default(SIGQUIT);
diff --git a/Src/init.c b/Src/init.c
index 40f46a804..6d005dce7 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -1134,6 +1134,7 @@ init_signals(void)
     winch_block();	/* See utils.c:preprompt() */
 #endif
     if (interact) {
+	install_handler(SIGPIPE);
 	install_handler(SIGALRM);
 	signal_ignore(SIGTERM);
     }
diff --git a/Src/signals.c b/Src/signals.c
index cb2b58161..84a2609e5 100644
--- a/Src/signals.c
+++ b/Src/signals.c
@@ -594,6 +594,17 @@ zhandler(int sig)
 	wait_for_processes();
         break;
  
+    case SIGPIPE:
+	if (!handletrap(SIGPIPE)) {
+	    if (!interact)
+		_exit(SIGPIPE);
+	    else if (!isatty(SHTTY)) {
+		stopmsg = 1;
+		zexit(SIGPIPE, 1);
+	    }
+	}
+	break;
+
     case SIGHUP:
         if (!handletrap(SIGHUP)) {
             stopmsg = 1;
@@ -897,6 +908,8 @@ removetrap(int sig)
 	noholdintr();
     } else if (sig == SIGHUP)
         install_handler(sig);
+    else if (sig == SIGPIPE && interact && !forklevel)
+        install_handler(sig);
     else if (sig && sig <= SIGCOUNT &&
 #ifdef SIGWINCH
              sig != SIGWINCH &&