Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: stopping "wait" in (sub)script ?

> > I cannot stop such command
> > 
> > $ for i in `cat ss`
> > for> do xvi $i &
> > for> wait
> > for> done
> yup, same here on IRIX 5.3 with 3.1.2-test1.  The `cat ss` is
> definitely necessary, there is no problem if it's replaced by a simple
> list of values.  Weird.

OK, now I got it.  The fix looks really simple, and I do hope that this is
really al that's needed.  entersubshell changes the terminal process group
to the subshell's newly created process group, and the main shell does not
reattach the terminal after the foreground process exits.  The simplest way
to reproduce the bug is

(:); while true; do; done

Which causes an uninterruptible infinite loop.

It is really surprising that this bug remained hidden for such a long
time.  An interactive shell always looses the terminal after executinh any
foreground command, and it is only reattached when the hbegin is called to
get the next line from the terminal.  This was probably the reason that
sometimes ^C did not interrupt loops started from an interactive shell.


*** Src/jobs.c	1997/05/09 04:55:51
--- Src/jobs.c	1997/05/15 06:57:44
*** 156,161 ****
--- 156,164 ----
      pgrp = gettygrp();           /* get process group of tty      */
+     if (isset(MONITOR) && pgrp == jn->gleader)
+ 	attachtty(mypgrp);
      /* is this job in the foreground of an interactive shell? */
      if ((jn->gleader == pgrp || (pgrp > 1 && kill(-pgrp, 0) == -1)) &&
  	!ttyfrozen && !val && !jn->stty_in_env)

Messages sorted by: Reverse Date, Date, Thread, Author