Fixed bugs handling (background) orphaned process groups. tty

writes and tty ioctls by processes in such groups must return
-1/EIO, but they were allowed.  tty reads were handled correctly.

Found by:	NIST PCTS
This commit is contained in:
Bruce Evans 1996-11-29 15:50:56 +00:00
parent 599ed91341
commit 8be1cbf1f4

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)tty.c 8.8 (Berkeley) 1/21/94
* $Id: tty.c,v 1.85 1996/11/29 15:06:09 bde Exp $
* $Id: tty.c,v 1.86 1996/11/29 15:23:42 bde Exp $
*/
/*-
@ -738,10 +738,12 @@ ttioctl(tp, cmd, data, flag)
case TIOCSETP:
case TIOCSLTC:
#endif
while (isbackground(curproc, tp) &&
p->p_pgrp->pg_jobc && (p->p_flag & P_PPWAIT) == 0 &&
while (isbackground(p, tp) &&
(p->p_flag & P_PPWAIT) == 0 &&
(p->p_sigignore & sigmask(SIGTTOU)) == 0 &&
(p->p_sigmask & sigmask(SIGTTOU)) == 0) {
if (p->p_pgrp->pg_jobc == 0)
return (EIO);
pgsignal(p->p_pgrp, SIGTTOU, 1);
error = ttysleep(tp, &lbolt, TTOPRI | PCATCH, "ttybg1",
0);
@ -1768,8 +1770,11 @@ loop:
if (isbackground(p, tp) &&
ISSET(tp->t_lflag, TOSTOP) && (p->p_flag & P_PPWAIT) == 0 &&
(p->p_sigignore & sigmask(SIGTTOU)) == 0 &&
(p->p_sigmask & sigmask(SIGTTOU)) == 0 &&
p->p_pgrp->pg_jobc) {
(p->p_sigmask & sigmask(SIGTTOU)) == 0) {
if (p->p_pgrp->pg_jobc == 0) {
error = EIO;
goto out;
}
pgsignal(p->p_pgrp, SIGTTOU, 1);
error = ttysleep(tp, &lbolt, TTIPRI | PCATCH, "ttybg4", 0);
if (error)