tty_pty.c revision 1.14 1 /*
2 * Copyright (c) 1982, 1986, 1989 The Regents of the University of California.
3 * 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
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
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 * from: @(#)tty_pty.c 7.21 (Berkeley) 5/30/91
34 * $Id: tty_pty.c,v 1.14 1993/11/12 15:15:57 cgd Exp $
35 */
36
37 /*
38 * Pseudo-teletype Driver
39 * (Actually two drivers, requiring two entries in 'cdevsw')
40 */
41 #include "pty.h"
42
43 #if NPTY > 0
44 #include "param.h"
45 #include "systm.h"
46 #include "ioctl.h"
47 #include "select.h"
48 #include "tty.h"
49 #include "conf.h"
50 #include "file.h"
51 #include "proc.h"
52 #include "uio.h"
53 #include "kernel.h"
54 #include "vnode.h"
55
56 #if NPTY == 1
57 #undef NPTY
58 #define NPTY 32 /* crude XXX */
59 #endif
60
61 #define BUFSIZ 100 /* Chunk size iomoved to/from user */
62
63 /*
64 * pts == /dev/tty[pqrs]?
65 * ptc == /dev/pty[pqrs]?
66 */
67 struct tty *pt_tty[NPTY];
68 struct pt_ioctl {
69 int pt_flags;
70 struct selinfo pt_selr, pt_selw;
71 u_char pt_send;
72 u_char pt_ucntl;
73 } pt_ioctl[NPTY];
74 int npty = NPTY; /* for pstat -t */
75
76 #define PF_COPEN 0x01 /* master open */
77 #define PF_SOPEN 0x02 /* slave open */
78 #define PF_PKT 0x08 /* packet mode */
79 #define PF_STOPPED 0x10 /* user told stopped */
80 #define PF_REMOTE 0x20 /* remote and flow controlled input */
81 #define PF_NOSTOP 0x40
82 #define PF_UCNTL 0x80 /* user control mode */
83
84 void ptcwakeup __P((struct tty *tp, int flag));
85
86 /*ARGSUSED*/
87 int
88 ptsopen(dev, flag, devtype, p)
89 dev_t dev;
90 int flag, devtype;
91 struct proc *p;
92 {
93 register struct tty *tp;
94 int error;
95
96 #ifdef lint
97 npty = npty;
98 #endif
99 if (minor(dev) >= NPTY)
100 return (ENXIO);
101 if(!pt_tty[minor(dev)]) {
102 tp = pt_tty[minor(dev)] = ttymalloc();
103 } else
104 tp = pt_tty[minor(dev)];
105 if ((tp->t_state & TS_ISOPEN) == 0) {
106 tp->t_state |= TS_WOPEN;
107 ttychars(tp); /* Set up default chars */
108 tp->t_iflag = TTYDEF_IFLAG;
109 tp->t_oflag = TTYDEF_OFLAG;
110 tp->t_lflag = TTYDEF_LFLAG;
111 tp->t_cflag = TTYDEF_CFLAG;
112 tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
113 ttsetwater(tp); /* would be done in xxparam() */
114 } else if (tp->t_state&TS_XCLUDE && p->p_ucred->cr_uid != 0)
115 return (EBUSY);
116 if (tp->t_oproc) /* Ctrlr still around. */
117 tp->t_state |= TS_CARR_ON;
118 while ((tp->t_state & TS_CARR_ON) == 0) {
119 tp->t_state |= TS_WOPEN;
120 if (flag&FNONBLOCK)
121 break;
122 if (error = ttysleep(tp, (caddr_t)&tp->t_rawq, TTIPRI | PCATCH,
123 ttopen, 0))
124 return (error);
125 }
126 if (error = (*linesw[tp->t_line].l_open)(dev, tp))
127 return (error);
128 pt_ioctl[minor(dev)].pt_flags |= PF_SOPEN;
129 ptcwakeup(tp, FREAD|FWRITE);
130 return (0);
131 }
132
133 int
134 ptsclose(dev, flag, mode, p)
135 dev_t dev;
136 int flag, mode;
137 struct proc *p;
138 {
139 register struct tty *tp;
140
141 tp = pt_tty[minor(dev)];
142 (*linesw[tp->t_line].l_close)(tp, flag);
143 ttyclose(tp);
144 ptcwakeup(tp, FREAD|FWRITE);
145 pt_ioctl[minor(dev)].pt_flags &= ~PF_SOPEN;
146 #ifdef broken /* session holds a ref to the tty; can't deallocate */
147 if ((pt_ioctl[minor(dev)].pt_flags & PF_COPEN) == 0) {
148 ttyfree(tp);
149 pt_tty[minor(dev)] = (struct tty *)NULL;
150 }
151 #endif
152 return(0);
153 }
154
155 int
156 ptsread(dev, uio, flag)
157 dev_t dev;
158 struct uio *uio;
159 int flag;
160 {
161 struct proc *p = curproc;
162 register struct tty *tp = pt_tty[minor(dev)];
163 register struct pt_ioctl *pti = &pt_ioctl[minor(dev)];
164 int error = 0;
165
166 again:
167 if (pti->pt_flags & PF_REMOTE) {
168 while (isbackground(p, tp)) {
169 if ((p->p_sigignore & sigmask(SIGTTIN)) ||
170 (p->p_sigmask & sigmask(SIGTTIN)) ||
171 p->p_pgrp->pg_jobc == 0 ||
172 p->p_flag&SPPWAIT)
173 return (EIO);
174 pgsignal(p->p_pgrp, SIGTTIN, 1);
175 if (error = ttysleep(tp, (caddr_t)&lbolt,
176 TTIPRI | PCATCH, ttybg, 0))
177 return (error);
178 }
179 if (tp->t_canq.c_cc == 0) {
180 if (flag & IO_NDELAY)
181 return (EWOULDBLOCK);
182 if (error = ttysleep(tp, (caddr_t)&tp->t_canq,
183 TTIPRI | PCATCH, ttyin, 0))
184 return (error);
185 goto again;
186 }
187 while (tp->t_canq.c_cc > 1 && uio->uio_resid > 0)
188 if (ureadc(getc(&tp->t_canq), uio) < 0) {
189 error = EFAULT;
190 break;
191 }
192 if (tp->t_canq.c_cc == 1)
193 (void) getc(&tp->t_canq);
194 if (tp->t_canq.c_cc)
195 return (error);
196 } else
197 if (tp->t_oproc)
198 error = (*linesw[tp->t_line].l_read)(tp, uio, flag);
199 ptcwakeup(tp, FWRITE);
200 return (error);
201 }
202
203 /*
204 * Write to pseudo-tty.
205 * Wakeups of controlling tty will happen
206 * indirectly, when tty driver calls ptsstart.
207 */
208 int
209 ptswrite(dev, uio, flag)
210 dev_t dev;
211 struct uio *uio;
212 int flag;
213 {
214 register struct tty *tp;
215
216 tp = pt_tty[minor(dev)];
217 if (tp->t_oproc == 0)
218 return (EIO);
219 return ((*linesw[tp->t_line].l_write)(tp, uio, flag));
220 }
221
222 /*
223 * Start output on pseudo-tty.
224 * Wake up process selecting or sleeping for input from controlling tty.
225 */
226 void
227 ptsstart(tp)
228 struct tty *tp;
229 {
230 register struct pt_ioctl *pti = &pt_ioctl[minor(tp->t_dev)];
231
232 if (tp->t_state & TS_TTSTOP)
233 return;
234 if (pti->pt_flags & PF_STOPPED) {
235 pti->pt_flags &= ~PF_STOPPED;
236 pti->pt_send = TIOCPKT_START;
237 }
238 ptcwakeup(tp, FREAD);
239 return;
240 }
241
242 void
243 ptcwakeup(tp, flag)
244 struct tty *tp;
245 int flag;
246 {
247 struct pt_ioctl *pti = &pt_ioctl[minor(tp->t_dev)];
248
249 if (flag & FREAD) {
250 selwakeup(&pti->pt_selr);
251 wakeup((caddr_t)&tp->t_outq.c_cl);
252 }
253 if (flag & FWRITE) {
254 selwakeup(&pti->pt_selw);
255 wakeup((caddr_t)&tp->t_rawq.c_cf);
256 }
257 }
258
259 /*ARGSUSED*/
260 #ifdef __STDC__
261 int
262 ptcopen(dev_t dev, int flag, int devtype, struct proc *p)
263 #else
264 int
265 ptcopen(dev, flag, devtype, p)
266 dev_t dev;
267 int flag, devtype;
268 struct proc *p;
269 #endif
270 {
271 register struct tty *tp;
272 struct pt_ioctl *pti;
273
274 if (minor(dev) >= NPTY)
275 return (ENXIO);
276 if(!pt_tty[minor(dev)]) {
277 tp = pt_tty[minor(dev)] = ttymalloc();
278 } else
279 tp = pt_tty[minor(dev)];
280 if (tp->t_oproc)
281 return (EIO);
282 tp->t_oproc = ptsstart;
283 (void)(*linesw[tp->t_line].l_modem)(tp, 1);
284 tp->t_lflag &= ~EXTPROC;
285 pti = &pt_ioctl[minor(dev)];
286 pti->pt_flags &= PF_SOPEN;
287 pti->pt_flags |= PF_COPEN;
288 pti->pt_send = 0;
289 pti->pt_ucntl = 0;
290 return (0);
291 }
292
293 extern struct tty *constty; /* -hv- 06.Oct.92*/
294
295 int
296 ptcclose(dev)
297 dev_t dev;
298 {
299 register struct tty *tp;
300
301 tp = pt_tty[minor(dev)];
302 (void)(*linesw[tp->t_line].l_modem)(tp, 0);
303 tp->t_state &= ~TS_CARR_ON;
304 tp->t_oproc = 0; /* mark closed */
305
306 /* XXX -hv- 6.Oct.92 this prevents the "hanging console bug" with X11 */
307 if (constty==tp)
308 constty = 0;
309
310 pt_ioctl[minor(dev)].pt_flags &= ~PF_COPEN;
311 #ifdef broken
312 if ((pt_ioctl[minor(dev)].pt_flags & PF_SOPEN) == 0) {
313 ttyfree(tp);
314 pt_tty[minor(dev)] = (struct tty *)NULL;
315 }
316 #endif
317 return (0);
318 }
319
320 int
321 ptcread(dev, uio, flag)
322 dev_t dev;
323 struct uio *uio;
324 int flag;
325 {
326 register struct tty *tp = pt_tty[minor(dev)];
327 struct pt_ioctl *pti = &pt_ioctl[minor(dev)];
328 u_char buf[BUFSIZ];
329 int error = 0, cc;
330
331 /*
332 * We want to block until the slave
333 * is open, and there's something to read;
334 * but if we lost the slave or we're NBIO,
335 * then return the appropriate error instead.
336 */
337 for (;;) {
338 if (tp->t_state&TS_ISOPEN) {
339 if (pti->pt_flags&PF_PKT && pti->pt_send) {
340 error = ureadc((int)pti->pt_send, uio);
341 if (error)
342 return (error);
343 if (pti->pt_send & TIOCPKT_IOCTL) {
344 cc = MIN(uio->uio_resid,
345 sizeof(tp->t_termios));
346 uiomove((caddr_t)&tp->t_termios, cc,
347 uio);
348 }
349 pti->pt_send = 0;
350 return (0);
351 }
352 if (pti->pt_flags&PF_UCNTL && pti->pt_ucntl) {
353 error = ureadc((int)pti->pt_ucntl, uio);
354 if (error)
355 return (error);
356 pti->pt_ucntl = 0;
357 return (0);
358 }
359 if (tp->t_outq.c_cc && (tp->t_state&TS_TTSTOP) == 0)
360 break;
361 }
362 if ((tp->t_state&TS_CARR_ON) == 0)
363 return (0); /* EOF */
364 if (flag & IO_NDELAY)
365 return (EWOULDBLOCK);
366 if (error = tsleep((caddr_t)&tp->t_outq.c_cl, TTIPRI | PCATCH,
367 ttyin, 0))
368 return (error);
369 }
370 if (pti->pt_flags & (PF_PKT|PF_UCNTL))
371 error = ureadc(0, uio);
372 while (uio->uio_resid > 0 && error == 0) {
373 cc = q_to_b(&tp->t_outq, buf, MIN(uio->uio_resid, BUFSIZ));
374 if (cc <= 0)
375 break;
376 error = uiomove(buf, cc, uio);
377 }
378 if (tp->t_outq.c_cc <= tp->t_lowat) {
379 if (tp->t_state&TS_ASLEEP) {
380 tp->t_state &= ~TS_ASLEEP;
381 wakeup((caddr_t)&tp->t_outq);
382 }
383 selwakeup(&tp->t_wsel);
384 }
385 return (error);
386 }
387
388 void
389 ptsstop(tp, flush)
390 register struct tty *tp;
391 int flush;
392 {
393 struct pt_ioctl *pti = &pt_ioctl[minor(tp->t_dev)];
394 int flag;
395
396 /* note: FLUSHREAD and FLUSHWRITE already ok */
397 if (flush == 0) {
398 flush = TIOCPKT_STOP;
399 pti->pt_flags |= PF_STOPPED;
400 } else
401 pti->pt_flags &= ~PF_STOPPED;
402 pti->pt_send |= flush;
403 /* change of perspective */
404 flag = 0;
405 if (flush & FREAD)
406 flag |= FWRITE;
407 if (flush & FWRITE)
408 flag |= FREAD;
409 ptcwakeup(tp, flag);
410 }
411
412 int
413 ptcselect(dev, rw, p)
414 dev_t dev;
415 int rw;
416 struct proc *p;
417 {
418 register struct tty *tp = pt_tty[minor(dev)];
419 struct pt_ioctl *pti = &pt_ioctl[minor(dev)];
420 int s;
421
422 if ((tp->t_state&TS_CARR_ON) == 0)
423 return (1);
424 switch (rw) {
425
426 case FREAD:
427 /*
428 * Need to block timeouts (ttrstart).
429 */
430 s = spltty();
431 if ((tp->t_state&TS_ISOPEN) &&
432 tp->t_outq.c_cc && (tp->t_state&TS_TTSTOP) == 0) {
433 splx(s);
434 return (1);
435 }
436 splx(s);
437 /* FALLTHROUGH */
438
439 case 0: /* exceptional */
440 if ((tp->t_state&TS_ISOPEN) &&
441 (pti->pt_flags&PF_PKT && pti->pt_send ||
442 pti->pt_flags&PF_UCNTL && pti->pt_ucntl))
443 return (1);
444 selrecord(p, &pti->pt_selr);
445 break;
446
447
448 case FWRITE:
449 if (tp->t_state&TS_ISOPEN) {
450 if (pti->pt_flags & PF_REMOTE) {
451 if (tp->t_canq.c_cc == 0)
452 return (1);
453 } else {
454 if (tp->t_rawq.c_cc + tp->t_canq.c_cc < TTYHOG-2)
455 return (1);
456 if (tp->t_canq.c_cc == 0 && (tp->t_iflag&ICANON))
457 return (1);
458 }
459 }
460 selrecord(p, &pti->pt_selw);
461 break;
462
463 }
464 return (0);
465 }
466
467 int
468 ptcwrite(dev, uio, flag)
469 dev_t dev;
470 register struct uio *uio;
471 int flag;
472 {
473 register struct tty *tp = pt_tty[minor(dev)];
474 register u_char *cp;
475 register int cc = 0;
476 u_char locbuf[BUFSIZ];
477 int cnt = 0;
478 struct pt_ioctl *pti = &pt_ioctl[minor(dev)];
479 int error = 0;
480
481 again:
482 if ((tp->t_state&TS_ISOPEN) == 0)
483 goto block;
484 if (pti->pt_flags & PF_REMOTE) {
485 if (tp->t_canq.c_cc)
486 goto block;
487 while (uio->uio_resid > 0 && tp->t_canq.c_cc < TTYHOG - 1) {
488 if (cc == 0) {
489 cc = min(uio->uio_resid, BUFSIZ);
490 cc = min(cc, TTYHOG - 1 - tp->t_canq.c_cc);
491 cp = locbuf;
492 error = uiomove((caddr_t)cp, cc, uio);
493 if (error)
494 return (error);
495 /* check again for safety */
496 if ((tp->t_state&TS_ISOPEN) == 0)
497 return (EIO);
498 }
499 if (cc)
500 (void) b_to_q(cp, cc, &tp->t_canq);
501 cc = 0;
502 }
503 (void) putc(0, &tp->t_canq);
504 ttwakeup(tp);
505 wakeup((caddr_t)&tp->t_canq);
506 return (0);
507 }
508 while (uio->uio_resid > 0) {
509 if (cc == 0) {
510 cc = min(uio->uio_resid, BUFSIZ);
511 cp = locbuf;
512 error = uiomove((caddr_t)cp, cc, uio);
513 if (error)
514 return (error);
515 /* check again for safety */
516 if ((tp->t_state&TS_ISOPEN) == 0)
517 return (EIO);
518 }
519 while (cc > 0) {
520 if ((tp->t_rawq.c_cc + tp->t_canq.c_cc) >= TTYHOG - 2 &&
521 (tp->t_canq.c_cc > 0 || !(tp->t_iflag&ICANON))) {
522 wakeup((caddr_t)&tp->t_rawq);
523 goto block;
524 }
525 (*linesw[tp->t_line].l_rint)(*cp++, tp);
526 cnt++;
527 cc--;
528 }
529 cc = 0;
530 }
531 return (0);
532 block:
533 /*
534 * Come here to wait for slave to open, for space
535 * in outq, or space in rawq.
536 */
537 if ((tp->t_state&TS_CARR_ON) == 0)
538 return (EIO);
539 if (flag & IO_NDELAY) {
540 /* adjust for data copied in but not written */
541 uio->uio_resid += cc;
542 if (cnt == 0)
543 return (EWOULDBLOCK);
544 return (0);
545 }
546 if (error = tsleep((caddr_t)&tp->t_rawq.c_cf, TTOPRI | PCATCH,
547 ttyout, 0)) {
548 /* adjust for data copied in but not written */
549 uio->uio_resid += cc;
550 return (error);
551 }
552 goto again;
553 }
554
555 /*ARGSUSED*/
556 int
557 ptyioctl(dev, cmd, data, flag)
558 caddr_t data;
559 int cmd, flag;
560 dev_t dev;
561 {
562 register struct tty *tp = pt_tty[minor(dev)];
563 register struct pt_ioctl *pti = &pt_ioctl[minor(dev)];
564 register u_char *cc = tp->t_cc;
565 int stop, error;
566
567 /*
568 * IF CONTROLLER STTY THEN MUST FLUSH TO PREVENT A HANG.
569 * ttywflush(tp) will hang if there are characters in the outq.
570 */
571 if (cmd == TIOCEXT) {
572 /*
573 * When the EXTPROC bit is being toggled, we need
574 * to send an TIOCPKT_IOCTL if the packet driver
575 * is turned on.
576 */
577 if (*(int *)data) {
578 if (pti->pt_flags & PF_PKT) {
579 pti->pt_send |= TIOCPKT_IOCTL;
580 ptcwakeup(tp, FREAD);
581 }
582 tp->t_lflag |= EXTPROC;
583 } else {
584 if ((tp->t_state & EXTPROC) &&
585 (pti->pt_flags & PF_PKT)) {
586 pti->pt_send |= TIOCPKT_IOCTL;
587 ptcwakeup(tp, FREAD);
588 }
589 tp->t_lflag &= ~EXTPROC;
590 }
591 return(0);
592 } else
593 if (cdevsw[major(dev)].d_open == ptcopen)
594 switch (cmd) {
595
596 case TIOCGPGRP:
597 /*
598 * We aviod calling ttioctl on the controller since,
599 * in that case, tp must be the controlling terminal.
600 */
601 *(int *)data = tp->t_pgrp ? tp->t_pgrp->pg_id : 0;
602 return (0);
603
604 case TIOCPKT:
605 if (*(int *)data) {
606 if (pti->pt_flags & PF_UCNTL)
607 return (EINVAL);
608 pti->pt_flags |= PF_PKT;
609 } else
610 pti->pt_flags &= ~PF_PKT;
611 return (0);
612
613 case TIOCUCNTL:
614 if (*(int *)data) {
615 if (pti->pt_flags & PF_PKT)
616 return (EINVAL);
617 pti->pt_flags |= PF_UCNTL;
618 } else
619 pti->pt_flags &= ~PF_UCNTL;
620 return (0);
621
622 case TIOCREMOTE:
623 if (*(int *)data)
624 pti->pt_flags |= PF_REMOTE;
625 else
626 pti->pt_flags &= ~PF_REMOTE;
627 ttyflush(tp, FREAD|FWRITE);
628 return (0);
629
630 #ifdef COMPAT_43
631 /* wkt */
632 case TIOCSETP:
633 case TIOCSETN:
634 #endif
635 case TIOCSETD:
636 case TIOCSETA:
637 case TIOCSETAW:
638 case TIOCSETAF:
639 flushq(&tp->t_outq);
640 break;
641
642 case TIOCSIG:
643 if (*(unsigned int *)data >= NSIG)
644 return(EINVAL);
645 if ((tp->t_lflag&NOFLSH) == 0)
646 ttyflush(tp, FREAD|FWRITE);
647 pgsignal(tp->t_pgrp, *(unsigned int *)data, 1);
648 if ((*(unsigned int *)data == SIGINFO) &&
649 ((tp->t_lflag&NOKERNINFO) == 0))
650 ttyinfo(tp);
651 return(0);
652 }
653 error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag);
654 if (error < 0)
655 error = ttioctl(tp, cmd, data, flag);
656 /*
657 * Since we use the tty queues internally,
658 * pty's can't be switched to disciplines which overwrite
659 * the queues. We can't tell anything about the discipline
660 * from here...
661 */
662 if (linesw[tp->t_line].l_rint != ttyinput) {
663 (*linesw[tp->t_line].l_close)(tp, flag);
664 tp->t_line = TTYDISC;
665 (void)(*linesw[tp->t_line].l_open)(dev, tp);
666 error = ENOTTY;
667 }
668 if (error < 0) {
669 if (pti->pt_flags & PF_UCNTL &&
670 (cmd & ~0xff) == UIOCCMD(0)) {
671 if (cmd & 0xff) {
672 pti->pt_ucntl = (u_char)cmd;
673 ptcwakeup(tp, FREAD);
674 }
675 return (0);
676 }
677 error = ENOTTY;
678 }
679 /*
680 * If external processing and packet mode send ioctl packet.
681 */
682 if ((tp->t_lflag&EXTPROC) && (pti->pt_flags & PF_PKT)) {
683 switch(cmd) {
684 case TIOCSETA:
685 case TIOCSETAW:
686 case TIOCSETAF:
687 #ifdef COMPAT_43
688 /* wkt */
689 case TIOCSETP:
690 case TIOCSETN:
691 case TIOCSETC:
692 case TIOCSLTC:
693 case TIOCLBIS:
694 case TIOCLBIC:
695 case TIOCLSET:
696 #endif
697 pti->pt_send |= TIOCPKT_IOCTL;
698 default:
699 break;
700 }
701 }
702 stop = (tp->t_iflag & IXON) && CCEQ(cc[VSTOP], CTRL('s'))
703 && CCEQ(cc[VSTART], CTRL('q'));
704 if (pti->pt_flags & PF_NOSTOP) {
705 if (stop) {
706 pti->pt_send &= ~TIOCPKT_NOSTOP;
707 pti->pt_send |= TIOCPKT_DOSTOP;
708 pti->pt_flags &= ~PF_NOSTOP;
709 ptcwakeup(tp, FREAD);
710 }
711 } else {
712 if (!stop) {
713 pti->pt_send &= ~TIOCPKT_DOSTOP;
714 pti->pt_send |= TIOCPKT_NOSTOP;
715 pti->pt_flags |= PF_NOSTOP;
716 ptcwakeup(tp, FREAD);
717 }
718 }
719 return (error);
720 }
721 #endif
722