zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: 3.1.5-pws-17: read after pipeline bug
@ 1999-05-08 16:36 Peter Stephenson
  0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 1999-05-08 16:36 UTC (permalink / raw)
  To: Zsh hackers list

This looks like being an old bug, it's also in 3.0.5.

zsh -f
% echo foo | read foo; read foo
%

The (interactive) shell doesn't wait.  It turns out the read gets an EIO
--- repeatedly, so it's not a hang over from the previous read.

I discovered read foo </dev/tty also didn't work, while if there was an
intervening external command it did.  After almost two hours of fruitless
searching when I'd almost given up (oddly enough, this has happened to me
before, even with zsh), it occurred to me to wonder about tty process
groups, which get reset after an external command but not an internal one.
This seemed to be the problem.  So the following does the check for
resetting the process group even if the pipeline which just finished had a
builtin at its tail end.  Some version of this should go into 3.0.6.

--- Src/jobs.c.eio	Sat May  8 14:50:27 1999
+++ Src/jobs.c	Sat May  8 18:33:45 1999
@@ -180,11 +180,16 @@
     } else {                   /* job is done, so remember return value */
 	lastval2 = val;
 	/* If last process was run in the current shell, keep old status
-	 * and let it handle its own traps
+	 * and let it handle its own traps, but always allow the test
+	 * for the pgrp.
 	 */
-	if (job == thisjob && !(jn->stat & STAT_CURSH)) {
-	  lastval = val;
-	  inforeground = 1;
+	if (job == thisjob) {
+	    if (jn->stat & STAT_CURSH)
+		inforeground = 1;
+	    else {
+		lastval = val;
+		inforeground = 2;
+	    }
 	}
     }
 
@@ -223,7 +228,7 @@
      * process group from the shell, so the shell will not receive     *
      * terminal signals, therefore we we pretend that the shell got    *
      * the signal too.                                                 */
-    if (inforeground && isset(MONITOR) && WIFSIGNALED(status)) {
+    if (inforeground == 2 && isset(MONITOR) && WIFSIGNALED(status)) {
 	int sig = WTERMSIG(status);
 
 	if (sig == SIGINT || sig == SIGQUIT) {

-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1999-05-08 17:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-05-08 16:36 PATCH: 3.1.5-pws-17: read after pipeline bug Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).