mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-11 00:51:05 +02:00
17859: Philippe Troin: better handling of process groups interactively.
This commit is contained in:
parent
a46aee1188
commit
14f39707cb
2 changed files with 33 additions and 5 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2002-11-04 Peter Stephenson <pws@csr.com>
|
||||||
|
|
||||||
|
* 17859: Philippe Troin <phil@fifi.org>: Src/init.c: Better
|
||||||
|
handling of becoming process group leader in an interactive
|
||||||
|
process. We could end up with two shells reading from the
|
||||||
|
terminal at once.
|
||||||
|
|
||||||
2002-10-31 Wayne Davison <wayned@users.sourceforge.net>
|
2002-10-31 Wayne Davison <wayned@users.sourceforge.net>
|
||||||
|
|
||||||
* 17881: Src/builtin.c, Src/params.c: made the elapsed time in the
|
* 17881: Src/builtin.c, Src/params.c: made the elapsed time in the
|
||||||
|
|
31
Src/init.c
31
Src/init.c
|
@ -457,19 +457,40 @@ init_io(void)
|
||||||
opts[USEZLE] = 0;
|
opts[USEZLE] = 0;
|
||||||
|
|
||||||
#ifdef JOB_CONTROL
|
#ifdef JOB_CONTROL
|
||||||
/* If interactive, make the shell the foreground process */
|
/* If interactive, make sure the shell is in the foreground and is the
|
||||||
|
* process group leader.
|
||||||
|
*/
|
||||||
|
mypid = (zlong)getpid();
|
||||||
if (opts[MONITOR] && interact && (SHTTY != -1)) {
|
if (opts[MONITOR] && interact && (SHTTY != -1)) {
|
||||||
if ((mypgrp = GETPGRP()) > 0) {
|
if ((mypgrp = GETPGRP()) > 0) {
|
||||||
|
sigset_t blockset, oldset;
|
||||||
|
sigemptyset(&blockset);
|
||||||
|
sigaddset(&blockset, SIGTTIN);
|
||||||
|
sigaddset(&blockset, SIGTTOU);
|
||||||
|
sigaddset(&blockset, SIGTSTP);
|
||||||
|
oldset = signal_block(blockset);
|
||||||
while ((ttpgrp = gettygrp()) != -1 && ttpgrp != mypgrp) {
|
while ((ttpgrp = gettygrp()) != -1 && ttpgrp != mypgrp) {
|
||||||
sleep(1); /* give parent time to change pgrp */
|
|
||||||
mypgrp = GETPGRP();
|
mypgrp = GETPGRP();
|
||||||
if (mypgrp == mypid)
|
if (mypgrp == mypid) {
|
||||||
attachtty(mypgrp);
|
signal_setmask(oldset);
|
||||||
|
attachtty(mypgrp); /* Might generate SIGT* */
|
||||||
|
signal_block(blockset);
|
||||||
|
}
|
||||||
if (mypgrp == gettygrp())
|
if (mypgrp == gettygrp())
|
||||||
break;
|
break;
|
||||||
killpg(mypgrp, SIGTTIN);
|
signal_setmask(oldset);
|
||||||
|
read(0, NULL, 0); /* Might generate SIGT* */
|
||||||
|
signal_block(blockset);
|
||||||
mypgrp = GETPGRP();
|
mypgrp = GETPGRP();
|
||||||
}
|
}
|
||||||
|
if (mypgrp != mypid) {
|
||||||
|
if (setpgrp(0, 0) == 0) {
|
||||||
|
mypgrp = mypid;
|
||||||
|
attachtty(mypgrp);
|
||||||
|
} else
|
||||||
|
opts[MONITOR] = 0;
|
||||||
|
}
|
||||||
|
signal_setmask(oldset);
|
||||||
} else
|
} else
|
||||||
opts[MONITOR] = 0;
|
opts[MONITOR] = 0;
|
||||||
} else
|
} else
|
||||||
|
|
Loading…
Reference in a new issue