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

PATCH: 3.1.6-dev-17 (Was: BUG: backgrounding zsh does bad tty stuff)



Bart Schaefer wrote about Re: BUG: backgrounding zsh does bad tty stuff:
:On Feb 12,  5:03am, Geoff Wing wrote:
:} Subject: BUG: backgrounding zsh does bad tty stuff
:} % zsh-3.0.7 -f
:} % echo $SHLVL
:} 2
:} % zsh-3.0.7 -f &
:} [1] 19784
:
:I immediately get
:[1]  + suspended (tty output)  zsh -f

:What operating system are you using?

NetBSD/i386 (current)

:However, what did you expect?

I expected to get what you got. 

:There's even a loop in init.c:init_io() where zsh repeatedly attempts to
:force itself to be the tty foreground process, sending the pgrp leader
:a SIGTTIN and then attempting to grab the tty.  Not pretty, but it has
:been there for a very long time.

Yes, since 2.2. Note that bash (2.03) has something similar but bash still
works properly.
My problem is that zsh gets past that loop when it should be stuck there.
This seems to fix it for me:  we shouldn't be making ourself the process
group leader for the terminal until our parent has told has we're really
the process group leader.
Also, I don't know why the sleep(1) is in there.  It should hang on the
killpg() - though it may be needed to compensate for some other weird
occurrence and possibly shouldn't be taken out?

*** Src/init.c.org	Tue Jan 25 06:25:59 2000
--- Src/init.c	Sat Feb 12 23:13:02 2000
***************
*** 394,403 ****
  #ifdef JOB_CONTROL
      /* If interactive, make the shell the foreground process */
      if (opts[MONITOR] && interact && (SHTTY != -1)) {
- 	attachtty(GETPGRP());
  	if ((mypgrp = GETPGRP()) > 0) {
  	    while ((ttpgrp = gettygrp()) != -1 && ttpgrp != mypgrp) {
- 		sleep(1);
  		mypgrp = GETPGRP();
  		if (mypgrp == gettygrp())
  		    break;
--- 394,401 ----
***************
*** 408,413 ****
--- 406,412 ----
  	    opts[MONITOR] = 0;
      } else
  	opts[MONITOR] = 0;
+     attachtty(GETPGRP());
  #else
      opts[MONITOR] = 0;
  #endif

-- 
Geoff Wing : <gcw@xxxxxxxxx>     Work URL: http://www.primenet.com.au/
Rxvt Stuff : <gcw@xxxxxxxx>      Ego URL : http://pobox.com/~gcw/
Zsh Stuff  : <gcw@xxxxxxx>       Phone   : (Australia) 0413 431 874



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