tty.c (51756) | tty.c (51791) |
---|---|
1/*- 2 * Copyright (c) 1982, 1986, 1990, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 22 unchanged lines hidden (view full) --- 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)tty.c 8.8 (Berkeley) 1/21/94 | 1/*- 2 * Copyright (c) 1982, 1986, 1990, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 22 unchanged lines hidden (view full) --- 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)tty.c 8.8 (Berkeley) 1/21/94 |
39 * $FreeBSD: head/sys/kern/tty.c 51756 1999-09-28 11:45:31Z phk $ | 39 * $FreeBSD: head/sys/kern/tty.c 51791 1999-09-29 15:03:48Z marcel $ |
40 */ 41 42/*- 43 * TODO: 44 * o Fix races for sending the start char in ttyflush(). 45 * o Handle inter-byte timeout for "MIN > 0, TIME > 0" in ttyselect(). 46 * With luck, there will be MIN chars before select() returns(). 47 * o Handle CLOCAL consistently for ptys. Perhaps disallow setting it. --- 686 unchanged lines hidden (view full) --- 734 case TIOCLBIS: 735 case TIOCLSET: 736 case TIOCSETC: 737 case OTIOCSETD: 738 case TIOCSETN: 739 case TIOCSETP: 740 case TIOCSLTC: 741#endif | 40 */ 41 42/*- 43 * TODO: 44 * o Fix races for sending the start char in ttyflush(). 45 * o Handle inter-byte timeout for "MIN > 0, TIME > 0" in ttyselect(). 46 * With luck, there will be MIN chars before select() returns(). 47 * o Handle CLOCAL consistently for ptys. Perhaps disallow setting it. --- 686 unchanged lines hidden (view full) --- 734 case TIOCLBIS: 735 case TIOCLSET: 736 case TIOCSETC: 737 case OTIOCSETD: 738 case TIOCSETN: 739 case TIOCSETP: 740 case TIOCSLTC: 741#endif |
742 while (isbackground(p, tp) && 743 (p->p_flag & P_PPWAIT) == 0 && 744 (p->p_sigignore & sigmask(SIGTTOU)) == 0 && 745 (p->p_sigmask & sigmask(SIGTTOU)) == 0) { | 742 while (isbackground(p, tp) && !(p->p_flag & P_PPWAIT) && 743 !SIGISMEMBER(p->p_sigignore, SIGTTOU) && 744 !SIGISMEMBER(p->p_sigmask, SIGTTOU)) { |
746 if (p->p_pgrp->pg_jobc == 0) 747 return (EIO); 748 pgsignal(p->p_pgrp, SIGTTOU, 1); 749 error = ttysleep(tp, &lbolt, TTOPRI | PCATCH, "ttybg1", 750 0); 751 if (error) 752 return (error); 753 } --- 689 unchanged lines hidden (view full) --- 1443 lflag = tp->t_lflag; /* XXX ttypend() clobbers it */ 1444 } 1445 1446 /* 1447 * Hang process if it's in the background. 1448 */ 1449 if (isbackground(p, tp)) { 1450 splx(s); | 745 if (p->p_pgrp->pg_jobc == 0) 746 return (EIO); 747 pgsignal(p->p_pgrp, SIGTTOU, 1); 748 error = ttysleep(tp, &lbolt, TTOPRI | PCATCH, "ttybg1", 749 0); 750 if (error) 751 return (error); 752 } --- 689 unchanged lines hidden (view full) --- 1442 lflag = tp->t_lflag; /* XXX ttypend() clobbers it */ 1443 } 1444 1445 /* 1446 * Hang process if it's in the background. 1447 */ 1448 if (isbackground(p, tp)) { 1449 splx(s); |
1451 if ((p->p_sigignore & sigmask(SIGTTIN)) || 1452 (p->p_sigmask & sigmask(SIGTTIN)) || 1453 p->p_flag & P_PPWAIT || p->p_pgrp->pg_jobc == 0) | 1450 if (SIGISMEMBER(p->p_sigignore, SIGTTIN) || 1451 SIGISMEMBER(p->p_sigmask, SIGTTIN) || 1452 (p->p_flag & P_PPWAIT) || p->p_pgrp->pg_jobc == 0) |
1454 return (EIO); 1455 pgsignal(p->p_pgrp, SIGTTIN, 1); 1456 error = ttysleep(tp, &lbolt, TTIPRI | PCATCH, "ttybg2", 0); 1457 if (error) 1458 return (error); 1459 goto loop; 1460 } 1461 --- 232 unchanged lines hidden (view full) --- 1694 * Sleeps here are not interruptible, but we return prematurely if new signals 1695 * arrive. 1696 */ 1697int 1698ttycheckoutq(tp, wait) 1699 register struct tty *tp; 1700 int wait; 1701{ | 1453 return (EIO); 1454 pgsignal(p->p_pgrp, SIGTTIN, 1); 1455 error = ttysleep(tp, &lbolt, TTIPRI | PCATCH, "ttybg2", 0); 1456 if (error) 1457 return (error); 1458 goto loop; 1459 } 1460 --- 232 unchanged lines hidden (view full) --- 1693 * Sleeps here are not interruptible, but we return prematurely if new signals 1694 * arrive. 1695 */ 1696int 1697ttycheckoutq(tp, wait) 1698 register struct tty *tp; 1699 int wait; 1700{ |
1702 int hiwat, s, oldsig; | 1701 int hiwat, s; 1702 sigset_t oldmask; |
1703 1704 hiwat = tp->t_ohiwat; | 1703 1704 hiwat = tp->t_ohiwat; |
1705 SIGEMPTYSET(oldmask); |
|
1705 s = spltty(); | 1706 s = spltty(); |
1706 oldsig = wait ? curproc->p_siglist : 0; | 1707 if (wait) 1708 oldmask = curproc->p_siglist; |
1707 if (tp->t_outq.c_cc > hiwat + OBUFSIZ + 100) 1708 while (tp->t_outq.c_cc > hiwat) { 1709 ttstart(tp); 1710 if (tp->t_outq.c_cc <= hiwat) 1711 break; | 1709 if (tp->t_outq.c_cc > hiwat + OBUFSIZ + 100) 1710 while (tp->t_outq.c_cc > hiwat) { 1711 ttstart(tp); 1712 if (tp->t_outq.c_cc <= hiwat) 1713 break; |
1712 if (wait == 0 || curproc->p_siglist != oldsig) { | 1714 if (!(wait && SIGSETEQ(curproc->p_siglist, oldmask))) { |
1713 splx(s); 1714 return (0); 1715 } 1716 SET(tp->t_state, TS_SO_OLOWAT); 1717 tsleep(TSA_OLOWAT(tp), PZERO - 1, "ttoutq", hz); 1718 } 1719 splx(s); 1720 return (1); --- 40 unchanged lines hidden (view full) --- 1761 goto loop; 1762 } 1763 splx(s); 1764 /* 1765 * Hang the process if it's in the background. 1766 */ 1767 p = curproc; 1768 if (isbackground(p, tp) && | 1715 splx(s); 1716 return (0); 1717 } 1718 SET(tp->t_state, TS_SO_OLOWAT); 1719 tsleep(TSA_OLOWAT(tp), PZERO - 1, "ttoutq", hz); 1720 } 1721 splx(s); 1722 return (1); --- 40 unchanged lines hidden (view full) --- 1763 goto loop; 1764 } 1765 splx(s); 1766 /* 1767 * Hang the process if it's in the background. 1768 */ 1769 p = curproc; 1770 if (isbackground(p, tp) && |
1769 ISSET(tp->t_lflag, TOSTOP) && (p->p_flag & P_PPWAIT) == 0 && 1770 (p->p_sigignore & sigmask(SIGTTOU)) == 0 && 1771 (p->p_sigmask & sigmask(SIGTTOU)) == 0) { | 1771 ISSET(tp->t_lflag, TOSTOP) && !(p->p_flag & P_PPWAIT) && 1772 !SIGISMEMBER(p->p_sigignore, SIGTTOU) && 1773 !SIGISMEMBER(p->p_sigmask, SIGTTOU)) { |
1772 if (p->p_pgrp->pg_jobc == 0) { 1773 error = EIO; 1774 goto out; 1775 } 1776 pgsignal(p->p_pgrp, SIGTTOU, 1); 1777 error = ttysleep(tp, &lbolt, TTIPRI | PCATCH, "ttybg4", 0); 1778 if (error) 1779 goto out; --- 694 unchanged lines hidden --- | 1774 if (p->p_pgrp->pg_jobc == 0) { 1775 error = EIO; 1776 goto out; 1777 } 1778 pgsignal(p->p_pgrp, SIGTTOU, 1); 1779 error = ttysleep(tp, &lbolt, TTIPRI | PCATCH, "ttybg4", 0); 1780 if (error) 1781 goto out; --- 694 unchanged lines hidden --- |