Deleted Added
full compact
pty.c (9619) pty.c (9624)
1/*
2 * Copyright (c) 1982, 1986, 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)tty_pty.c 8.2 (Berkeley) 9/23/93
1/*
2 * Copyright (c) 1982, 1986, 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)tty_pty.c 8.2 (Berkeley) 9/23/93
34 * $Id: tty_pty.c,v 1.11 1995/05/30 08:06:14 rgrimes Exp $
34 * $Id: tty_pty.c,v 1.12 1995/07/21 16:30:52 bde Exp $
35 */
36
37/*
38 * Pseudo-teletype Driver
39 * (Actually two drivers, requiring two entries in 'cdevsw')
40 */
41#include "pty.h" /* XXX */
42

--- 89 unchanged lines hidden (view full) ---

132 } else if (tp->t_state&TS_XCLUDE && p->p_ucred->cr_uid != 0)
133 return (EBUSY);
134 if (tp->t_oproc) /* Ctrlr still around. */
135 tp->t_state |= TS_CARR_ON;
136 while ((tp->t_state & TS_CARR_ON) == 0) {
137 if (flag&FNONBLOCK)
138 break;
139 error = ttysleep(tp, (caddr_t)&tp->t_rawq, TTIPRI | PCATCH,
35 */
36
37/*
38 * Pseudo-teletype Driver
39 * (Actually two drivers, requiring two entries in 'cdevsw')
40 */
41#include "pty.h" /* XXX */
42

--- 89 unchanged lines hidden (view full) ---

132 } else if (tp->t_state&TS_XCLUDE && p->p_ucred->cr_uid != 0)
133 return (EBUSY);
134 if (tp->t_oproc) /* Ctrlr still around. */
135 tp->t_state |= TS_CARR_ON;
136 while ((tp->t_state & TS_CARR_ON) == 0) {
137 if (flag&FNONBLOCK)
138 break;
139 error = ttysleep(tp, (caddr_t)&tp->t_rawq, TTIPRI | PCATCH,
140 ttopen, 0);
140 "ptsopn", 0);
141 if (error)
142 return (error);
143 }
144 error = (*linesw[tp->t_line].l_open)(dev, tp);
145 if (error == 0)
146 ptcwakeup(tp, FREAD|FWRITE);
147 return (error);
148}

--- 29 unchanged lines hidden (view full) ---

178 if (pti->pt_flags & PF_REMOTE) {
179 while (isbackground(p, tp)) {
180 if ((p->p_sigignore & sigmask(SIGTTIN)) ||
181 (p->p_sigmask & sigmask(SIGTTIN)) ||
182 p->p_pgrp->pg_jobc == 0 ||
183 p->p_flag & P_PPWAIT)
184 return (EIO);
185 pgsignal(p->p_pgrp, SIGTTIN, 1);
141 if (error)
142 return (error);
143 }
144 error = (*linesw[tp->t_line].l_open)(dev, tp);
145 if (error == 0)
146 ptcwakeup(tp, FREAD|FWRITE);
147 return (error);
148}

--- 29 unchanged lines hidden (view full) ---

178 if (pti->pt_flags & PF_REMOTE) {
179 while (isbackground(p, tp)) {
180 if ((p->p_sigignore & sigmask(SIGTTIN)) ||
181 (p->p_sigmask & sigmask(SIGTTIN)) ||
182 p->p_pgrp->pg_jobc == 0 ||
183 p->p_flag & P_PPWAIT)
184 return (EIO);
185 pgsignal(p->p_pgrp, SIGTTIN, 1);
186 error = ttysleep(tp, (caddr_t)&lbolt,
187 TTIPRI | PCATCH, ttybg, 0);
186 error = ttysleep(tp, &lbolt, TTIPRI | PCATCH, "ptsbg",
187 0);
188 if (error)
189 return (error);
190 }
191 if (tp->t_canq.c_cc == 0) {
192 if (flag & IO_NDELAY)
193 return (EWOULDBLOCK);
188 if (error)
189 return (error);
190 }
191 if (tp->t_canq.c_cc == 0) {
192 if (flag & IO_NDELAY)
193 return (EWOULDBLOCK);
194 error = ttysleep(tp, (caddr_t)&tp->t_canq,
195 TTIPRI | PCATCH, ttyin, 0);
194 error = ttysleep(tp, &tp->t_canq, TTIPRI | PCATCH,
195 "ptsin", 0);
196 if (error)
197 return (error);
198 goto again;
199 }
200 while (tp->t_canq.c_cc > 1 && uio->uio_resid > 0)
201 if (ureadc(getc(&tp->t_canq), uio) < 0) {
202 error = EFAULT;
203 break;

--- 152 unchanged lines hidden (view full) ---

356 }
357 if (tp->t_outq.c_cc && (tp->t_state&TS_TTSTOP) == 0)
358 break;
359 }
360 if ((tp->t_state&TS_CARR_ON) == 0)
361 return (0); /* EOF */
362 if (flag & IO_NDELAY)
363 return (EWOULDBLOCK);
196 if (error)
197 return (error);
198 goto again;
199 }
200 while (tp->t_canq.c_cc > 1 && uio->uio_resid > 0)
201 if (ureadc(getc(&tp->t_canq), uio) < 0) {
202 error = EFAULT;
203 break;

--- 152 unchanged lines hidden (view full) ---

356 }
357 if (tp->t_outq.c_cc && (tp->t_state&TS_TTSTOP) == 0)
358 break;
359 }
360 if ((tp->t_state&TS_CARR_ON) == 0)
361 return (0); /* EOF */
362 if (flag & IO_NDELAY)
363 return (EWOULDBLOCK);
364 error = tsleep((caddr_t)&tp->t_outq.c_cf, TTIPRI | PCATCH,
365 ttyin, 0);
364 error = tsleep(&tp->t_outq.c_cf, TTIPRI | PCATCH, "ptcin", 0);
366 if (error)
367 return (error);
368 }
369 if (pti->pt_flags & (PF_PKT|PF_UCNTL))
370 error = ureadc(0, uio);
371 while (uio->uio_resid > 0 && error == 0) {
372 cc = q_to_b(&tp->t_outq, buf, min(uio->uio_resid, BUFSIZ));
373 if (cc <= 0)

--- 163 unchanged lines hidden (view full) ---

537 return (EIO);
538 if (flag & IO_NDELAY) {
539 /* adjust for data copied in but not written */
540 uio->uio_resid += cc;
541 if (cnt == 0)
542 return (EWOULDBLOCK);
543 return (0);
544 }
365 if (error)
366 return (error);
367 }
368 if (pti->pt_flags & (PF_PKT|PF_UCNTL))
369 error = ureadc(0, uio);
370 while (uio->uio_resid > 0 && error == 0) {
371 cc = q_to_b(&tp->t_outq, buf, min(uio->uio_resid, BUFSIZ));
372 if (cc <= 0)

--- 163 unchanged lines hidden (view full) ---

536 return (EIO);
537 if (flag & IO_NDELAY) {
538 /* adjust for data copied in but not written */
539 uio->uio_resid += cc;
540 if (cnt == 0)
541 return (EWOULDBLOCK);
542 return (0);
543 }
545 error = tsleep((caddr_t)&tp->t_rawq.c_cl, TTOPRI | PCATCH, ttyout, 0);
544 error = tsleep(&tp->t_rawq.c_cl, TTOPRI | PCATCH, "ptcout", 0);
546 if (error) {
547 /* adjust for data copied in but not written */
548 uio->uio_resid += cc;
549 return (error);
550 }
551 goto again;
552}
553

--- 167 unchanged lines hidden ---
545 if (error) {
546 /* adjust for data copied in but not written */
547 uio->uio_resid += cc;
548 return (error);
549 }
550 goto again;
551}
552

--- 167 unchanged lines hidden ---