zsh-workers
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: Geoff Wing <gcw@pobox.com>
Cc: zsh-workers@sunsite.auc.dk
Subject: Re: PATCH: 3.1.6-dev-17 (Was: BUG: backgrounding zsh does bad tty stuff)
Date: Sat, 12 Feb 2000 18:00:25 +0000	[thread overview]
Message-ID: <1000212180025.ZM16739@candle.brasslantern.com> (raw)
In-Reply-To: <20000212231741.A20778@primenet.com.au>

On Feb 12, 11:17pm, Geoff Wing wrote:
} Subject: PATCH: 3.1.6-dev-17 (Was: BUG: backgrounding zsh does bad tty stu
}
} :There's even a loop in init.c:init_io() where zsh repeatedly attempts to
} :force itself to be the tty foreground process
} 
} 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.

If the parent has made zsh the tty group leader -- note we're testing
ttpgrp == mypgrp -- then why would zsh need to make itself the tty group
leader?  It doesn't make sense to me to call attachtty() *after* we've
already verified that zsh is the tty group leader.

Perhaps what you mean is that we should wait for our parent to put us in
our own process group before attempting to make that group the tty group?

That isn't what your patch accomplishes, though.

} Also, I don't know why the sleep(1) is in there.

Note that we call GETPGRP() both before and after the sleep(1).  The
sleep is there to give the parent a chance to assign zsh to its own
group, i.e., have the OS context-switch to the parent and back before
we attempt GETPGRP() the second time.

Try this patch instead of 9692.  The difference that I see with the
patch below is that instead of

[1]  + suspended (tty output)  Src/zsh -f

with zsh stopped in ioctl() (according to gdb), I instead get

[1]  + suspended (tty input)  Src/zsh -f

with zsh stopped in its own call to killpg() -- which I think is the
desired behavior.

Index: Src/init.c
===================================================================
@@ -399,11 +399,12 @@
 #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);
+		sleep(1);	/* give parent time to change pgrp */
 		mypgrp = GETPGRP();
+		if (mypgrp == mypid)
+		    attachtty(mypgrp);
 		if (mypgrp == gettygrp())
 		    break;
 		killpg(mypgrp, SIGTTIN);

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


  reply	other threads:[~2000-02-12 18:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-02-12  5:03 BUG: backgrounding zsh does bad tty stuff Geoff Wing
2000-02-12  5:58 ` Bart Schaefer
2000-02-12 12:17   ` PATCH: 3.1.6-dev-17 (Was: BUG: backgrounding zsh does bad tty stuff) Geoff Wing
2000-02-12 18:00     ` Bart Schaefer [this message]
2000-02-13  5:22       ` Geoff Wing

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1000212180025.ZM16739@candle.brasslantern.com \
    --to=schaefer@candle.brasslantern.com \
    --cc=gcw@pobox.com \
    --cc=zsh-workers@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).