Commit | Line | Data |
---|---|---|
a66e4149 | 1 | /* tty.c 4.22 82/03/15 */ |
89dc6dfb BJ |
2 | |
3 | /* | |
50e2732b | 4 | * TTY subroutines common to more than one line discipline |
89dc6dfb BJ |
5 | */ |
6 | #include "../h/param.h" | |
7 | #include "../h/systm.h" | |
8 | #include "../h/dir.h" | |
9 | #include "../h/user.h" | |
10 | #include "../h/tty.h" | |
11 | #include "../h/proc.h" | |
89dc6dfb BJ |
12 | #include "../h/inode.h" |
13 | #include "../h/file.h" | |
14 | #include "../h/reg.h" | |
15 | #include "../h/conf.h" | |
16 | #include "../h/buf.h" | |
d1778415 | 17 | #include "../h/dk.h" |
89dc6dfb BJ |
18 | |
19 | char partab[]; | |
20 | ||
89dc6dfb BJ |
21 | /* |
22 | * Input mapping table-- if an entry is non-zero, when the | |
23 | * corresponding character is typed preceded by "\" the escape | |
24 | * sequence is replaced by the table value. Mostly used for | |
25 | * upper-case only terminals. | |
26 | */ | |
27 | ||
28 | char maptab[] ={ | |
29 | 000,000,000,000,000,000,000,000, | |
30 | 000,000,000,000,000,000,000,000, | |
31 | 000,000,000,000,000,000,000,000, | |
32 | 000,000,000,000,000,000,000,000, | |
33 | 000,'|',000,000,000,000,000,'`', | |
34 | '{','}',000,000,000,000,000,000, | |
35 | 000,000,000,000,000,000,000,000, | |
36 | 000,000,000,000,000,000,000,000, | |
37 | 000,000,000,000,000,000,000,000, | |
38 | 000,000,000,000,000,000,000,000, | |
39 | 000,000,000,000,000,000,000,000, | |
40 | 000,000,000,000,000,000,'~',000, | |
41 | 000,'A','B','C','D','E','F','G', | |
42 | 'H','I','J','K','L','M','N','O', | |
43 | 'P','Q','R','S','T','U','V','W', | |
44 | 'X','Y','Z',000,000,000,000,000, | |
45 | }; | |
46 | ||
0d65848d BJ |
47 | short tthiwat[16] = |
48 | { 100,100,100,100,100,100,100,200,200,400,400,400,650,650,650,650 }; | |
49 | short ttlowat[16] = | |
50 | { 30, 30, 30, 30, 30, 30, 30, 50, 50,120,120,120,125,125,125,125 }; | |
51 | ||
89dc6dfb BJ |
52 | #define OBUFSIZ 100 |
53 | ||
89dc6dfb BJ |
54 | /* |
55 | * set default control characters. | |
56 | */ | |
57 | ttychars(tp) | |
58 | register struct tty *tp; | |
59 | { | |
8062c8a7 | 60 | |
89dc6dfb BJ |
61 | tun.t_intrc = CINTR; |
62 | tun.t_quitc = CQUIT; | |
63 | tun.t_startc = CSTART; | |
64 | tun.t_stopc = CSTOP; | |
65 | tun.t_eofc = CEOT; | |
66 | tun.t_brkc = CBRK; | |
67 | tp->t_erase = CERASE; | |
68 | tp->t_kill = CKILL; | |
8062c8a7 | 69 | /* begin local */ |
6fdc0335 BJ |
70 | tlun.t_suspc = CTRL(z); |
71 | tlun.t_dsuspc = CTRL(y); | |
8062c8a7 BJ |
72 | tlun.t_rprntc = CTRL(r); |
73 | tlun.t_flushc = CTRL(o); | |
74 | tlun.t_werasc = CTRL(w); | |
75 | tlun.t_lnextc = CTRL(v); | |
8062c8a7 BJ |
76 | tp->t_local = 0; |
77 | tp->t_lstate = 0; | |
78 | /* end local */ | |
89dc6dfb BJ |
79 | } |
80 | ||
81 | /* | |
50e2732b | 82 | * Wait for output to drain, then flush input waiting. |
89dc6dfb | 83 | */ |
50e2732b | 84 | wflushtty(tp) |
941944c9 | 85 | register struct tty *tp; |
89dc6dfb BJ |
86 | { |
87 | ||
50e2732b | 88 | (void) spl5(); |
4c67f645 BJ |
89 | while (tp->t_outq.c_cc && tp->t_state&TS_CARR_ON |
90 | && tp->t_oproc) { /* kludge for pty */ | |
50e2732b | 91 | (*tp->t_oproc)(tp); |
941944c9 | 92 | tp->t_state |= TS_ASLEEP; |
50e2732b BJ |
93 | sleep((caddr_t)&tp->t_outq, TTOPRI); |
94 | } | |
39697bd8 | 95 | flushtty(tp, FREAD); |
50e2732b | 96 | (void) spl0(); |
89dc6dfb BJ |
97 | } |
98 | ||
99 | /* | |
50e2732b | 100 | * flush all TTY queues |
89dc6dfb | 101 | */ |
50e2732b BJ |
102 | flushtty(tp, rw) |
103 | register struct tty *tp; | |
89dc6dfb | 104 | { |
50e2732b BJ |
105 | register s; |
106 | ||
50e2732b BJ |
107 | s = spl6(); |
108 | if (rw & FREAD) { | |
109 | while (getc(&tp->t_canq) >= 0) | |
110 | ; | |
111 | wakeup((caddr_t)&tp->t_rawq); | |
112 | } | |
113 | if (rw & FWRITE) { | |
114 | wakeup((caddr_t)&tp->t_outq); | |
941944c9 | 115 | tp->t_state &= ~TS_TTSTOP; |
39697bd8 | 116 | (*cdevsw[major(tp->t_dev)].d_stop)(tp, rw); |
50e2732b BJ |
117 | while (getc(&tp->t_outq) >= 0) |
118 | ; | |
119 | } | |
120 | if (rw & FREAD) { | |
121 | while (getc(&tp->t_rawq) >= 0) | |
122 | ; | |
123 | tp->t_delct = 0; | |
124 | tp->t_rocount = 0; /* local */ | |
125 | tp->t_rocol = 0; | |
126 | tp->t_lstate = 0; | |
127 | } | |
128 | splx(s); | |
89dc6dfb BJ |
129 | } |
130 | ||
50e2732b BJ |
131 | /* |
132 | * Send stop character on input overflow. | |
133 | */ | |
134 | ttyblock(tp) | |
135 | register struct tty *tp; | |
89dc6dfb | 136 | { |
50e2732b BJ |
137 | register x; |
138 | x = tp->t_rawq.c_cc + tp->t_canq.c_cc; | |
139 | if (tp->t_rawq.c_cc > TTYHOG) { | |
140 | flushtty(tp, FREAD|FWRITE); | |
941944c9 | 141 | tp->t_state &= ~TS_TBLOCK; |
50e2732b BJ |
142 | } |
143 | if (x >= TTYHOG/2) { | |
144 | if (putc(tun.t_stopc, &tp->t_outq)==0) { | |
941944c9 | 145 | tp->t_state |= TS_TBLOCK; |
50e2732b BJ |
146 | tp->t_char++; |
147 | ttstart(tp); | |
148 | } | |
149 | } | |
89dc6dfb BJ |
150 | } |
151 | ||
101ba270 | 152 | /* |
50e2732b BJ |
153 | * Restart typewriter output following a delay |
154 | * timeout. | |
155 | * The name of the routine is passed to the timeout | |
156 | * subroutine and it is called during a clock interrupt. | |
101ba270 | 157 | */ |
50e2732b | 158 | ttrstrt(tp) |
101ba270 | 159 | register struct tty *tp; |
101ba270 BJ |
160 | { |
161 | ||
545f5350 BJ |
162 | if (tp == 0) { |
163 | printf("ttrstrt: arg was 0!\n"); | |
164 | return; | |
165 | } | |
941944c9 | 166 | tp->t_state &= ~TS_TIMEOUT; |
50e2732b | 167 | ttstart(tp); |
101ba270 BJ |
168 | } |
169 | ||
89dc6dfb | 170 | /* |
50e2732b BJ |
171 | * Start output on the typewriter. It is used from the top half |
172 | * after some characters have been put on the output queue, | |
173 | * from the interrupt routine to transmit the next | |
174 | * character, and after a timeout has finished. | |
89dc6dfb | 175 | */ |
50e2732b BJ |
176 | ttstart(tp) |
177 | register struct tty *tp; | |
89dc6dfb | 178 | { |
50e2732b | 179 | register s; |
8062c8a7 | 180 | |
50e2732b | 181 | s = spl5(); |
4c67f645 BJ |
182 | if((tp->t_state&(TS_TIMEOUT|TS_TTSTOP|TS_BUSY)) == 0 && |
183 | tp->t_oproc) /* kludge for pty */ | |
50e2732b BJ |
184 | (*tp->t_oproc)(tp); |
185 | splx(s); | |
89dc6dfb BJ |
186 | } |
187 | ||
188 | /* | |
50e2732b | 189 | * Common code for tty ioctls. |
89dc6dfb | 190 | */ |
49c84d3f | 191 | /*ARGSUSED*/ |
0cbf0d70 | 192 | ttioctl(tp, com, addr, flag) |
89dc6dfb BJ |
193 | register struct tty *tp; |
194 | caddr_t addr; | |
195 | { | |
0cbf0d70 | 196 | int dev; |
89dc6dfb | 197 | unsigned t; |
8062c8a7 | 198 | struct sgttyb iocb; |
de857265 | 199 | struct clist tq; |
89dc6dfb | 200 | extern int nldisp; |
50450a20 | 201 | register c; |
da1392b6 | 202 | int temp; |
89dc6dfb | 203 | |
c6fe3a50 BJ |
204 | /* |
205 | * This is especially so that isatty() will | |
206 | * fail when carrier is gone. | |
207 | */ | |
941944c9 | 208 | if ((tp->t_state&TS_CARR_ON) == 0) { |
c6fe3a50 BJ |
209 | u.u_error = EBADF; |
210 | return (1); | |
211 | } | |
212 | ||
0cbf0d70 | 213 | dev = tp->t_dev; |
50e2732b BJ |
214 | /* |
215 | * If the ioctl involves modification, | |
216 | * insist on being able to write the device, | |
217 | * and hang if in the background. | |
218 | */ | |
219 | switch(com) { | |
220 | ||
c6fe3a50 BJ |
221 | case TIOCSETD: |
222 | case TIOCSETP: | |
223 | case TIOCSETN: | |
50e2732b BJ |
224 | case TIOCFLUSH: |
225 | case TIOCSETC: | |
226 | case TIOCSLTC: | |
227 | case TIOCSPGRP: | |
228 | case TIOCLBIS: | |
229 | case TIOCLBIC: | |
230 | case TIOCLSET: | |
231 | case TIOCSTI: | |
c6fe3a50 | 232 | /* this is reasonable, but impractical... |
50e2732b BJ |
233 | if ((flag & FWRITE) == 0) { |
234 | u.u_error = EBADF; | |
235 | return (1); | |
236 | } | |
c6fe3a50 | 237 | */ |
50e2732b BJ |
238 | while (tp->t_line == NTTYDISC && |
239 | u.u_procp->p_pgrp != tp->t_pgrp && tp == u.u_ttyp && | |
240 | (u.u_procp->p_flag&SVFORK) == 0 && | |
241 | u.u_signal[SIGTTOU] != SIG_IGN && | |
022f2340 BJ |
242 | u.u_signal[SIGTTOU] != SIG_HOLD |
243 | /* | |
244 | && | |
50e2732b | 245 | (u.u_procp->p_flag&SDETACH)==0) { |
022f2340 BJ |
246 | */ |
247 | ) { | |
50e2732b BJ |
248 | gsignal(u.u_procp->p_pgrp, SIGTTOU); |
249 | sleep((caddr_t)&lbolt, TTOPRI); | |
250 | } | |
251 | break; | |
252 | } | |
253 | ||
254 | /* | |
255 | * Process the ioctl. | |
256 | */ | |
89dc6dfb BJ |
257 | switch(com) { |
258 | ||
259 | /* | |
50e2732b | 260 | * Get discipline number |
89dc6dfb BJ |
261 | */ |
262 | case TIOCGETD: | |
263 | t = tp->t_line; | |
264 | if (copyout((caddr_t)&t, addr, sizeof(t))) | |
265 | u.u_error = EFAULT; | |
266 | break; | |
267 | ||
268 | /* | |
50e2732b | 269 | * Set line discipline |
89dc6dfb BJ |
270 | */ |
271 | case TIOCSETD: | |
272 | if (copyin(addr, (caddr_t)&t, sizeof(t))) { | |
273 | u.u_error = EFAULT; | |
274 | break; | |
275 | } | |
276 | if (t >= nldisp) { | |
277 | u.u_error = ENXIO; | |
278 | break; | |
279 | } | |
8062c8a7 | 280 | (void) spl5(); |
89dc6dfb BJ |
281 | if (tp->t_line) |
282 | (*linesw[tp->t_line].l_close)(tp); | |
283 | if (t) | |
284 | (*linesw[t].l_open)(dev, tp, addr); | |
285 | if (u.u_error==0) | |
286 | tp->t_line = t; | |
8062c8a7 | 287 | (void) spl0(); |
89dc6dfb BJ |
288 | break; |
289 | ||
152c2598 BJ |
290 | /* |
291 | * Prevent more opens on channel | |
292 | */ | |
293 | case TIOCEXCL: | |
294 | tp->t_state |= TS_XCLUDE; | |
295 | break; | |
296 | ||
297 | case TIOCNXCL: | |
298 | tp->t_state &= ~TS_XCLUDE; | |
299 | break; | |
300 | ||
89dc6dfb BJ |
301 | /* |
302 | * Set new parameters | |
303 | */ | |
304 | case TIOCSETP: | |
de857265 | 305 | case TIOCSETN: |
89dc6dfb BJ |
306 | if (copyin(addr, (caddr_t)&iocb, sizeof(iocb))) { |
307 | u.u_error = EFAULT; | |
308 | return(1); | |
309 | } | |
101ba270 | 310 | (void) spl5(); |
e1d74936 BJ |
311 | if (tp->t_flags&RAW || iocb.sg_flags&RAW || |
312 | com == TIOCSETP) | |
313 | wflushtty(tp); | |
314 | else if ((tp->t_flags&CBREAK) != (iocb.sg_flags&CBREAK)) { | |
315 | if (iocb.sg_flags & CBREAK) { | |
316 | catq(&tp->t_rawq, &tp->t_canq); | |
317 | tq = tp->t_rawq; | |
318 | tp->t_rawq = tp->t_canq; | |
319 | tp->t_canq = tq; | |
320 | } else { | |
321 | tp->t_local |= LPENDIN; | |
322 | ttwakeup(tp); | |
8062c8a7 BJ |
323 | } |
324 | } | |
e1d74936 BJ |
325 | tp->t_ispeed = iocb.sg_ispeed; |
326 | tp->t_ospeed = iocb.sg_ospeed; | |
8062c8a7 BJ |
327 | tp->t_erase = iocb.sg_erase; |
328 | tp->t_kill = iocb.sg_kill; | |
329 | tp->t_flags = iocb.sg_flags; | |
627c86ee | 330 | if (tp->t_flags & RAW) { |
941944c9 | 331 | tp->t_state &= ~TS_TTSTOP; |
627c86ee KB |
332 | ttstart(tp); |
333 | } | |
101ba270 | 334 | (void) spl0(); |
89dc6dfb BJ |
335 | break; |
336 | ||
337 | /* | |
50e2732b | 338 | * Send current parameters to user |
89dc6dfb BJ |
339 | */ |
340 | case TIOCGETP: | |
8062c8a7 BJ |
341 | iocb.sg_ispeed = tp->t_ispeed; |
342 | iocb.sg_ospeed = tp->t_ospeed; | |
343 | iocb.sg_erase = tp->t_erase; | |
344 | iocb.sg_kill = tp->t_kill; | |
345 | iocb.sg_flags = tp->t_flags; | |
89dc6dfb BJ |
346 | if (copyout((caddr_t)&iocb, addr, sizeof(iocb))) |
347 | u.u_error = EFAULT; | |
348 | break; | |
349 | ||
350 | /* | |
351 | * Hang up line on last close | |
352 | */ | |
89dc6dfb | 353 | case TIOCHPCL: |
941944c9 | 354 | tp->t_state |= TS_HUPCLS; |
89dc6dfb BJ |
355 | break; |
356 | ||
7d973a4d KB |
357 | case TIOCFLUSH: { |
358 | int flags; | |
359 | if (addr == 0) | |
360 | flags = FREAD|FWRITE; | |
361 | else if (copyin(addr, (caddr_t)&flags, sizeof (flags))) { | |
362 | u.u_error = EFAULT; | |
7344d489 | 363 | return(1); |
7d973a4d KB |
364 | } |
365 | flushtty(tp, flags); | |
89dc6dfb | 366 | break; |
4568c08e | 367 | } |
89dc6dfb | 368 | |
941944c9 BJ |
369 | case FIONBIO: { |
370 | int nbio; | |
371 | if (copyin(addr, (caddr_t)&nbio, sizeof (nbio))) { | |
372 | u.u_error = EFAULT; | |
373 | return(1); | |
374 | } | |
375 | if (nbio) | |
376 | tp->t_state |= TS_NBIO; | |
377 | else | |
378 | tp->t_state &= ~TS_NBIO; | |
379 | break; | |
380 | } | |
381 | ||
a66e4149 BJ |
382 | case FIOASYNC: { |
383 | int async; | |
384 | if (copyin(addr, (caddr_t)&async, sizeof (async))) { | |
385 | u.u_error = EFAULT; | |
386 | return(1); | |
387 | } | |
388 | if (async) | |
389 | tp->t_state |= TS_ASYNC; | |
390 | else | |
391 | tp->t_state &= ~TS_ASYNC; | |
392 | break; | |
393 | } | |
394 | ||
89dc6dfb | 395 | /* |
50e2732b | 396 | * Set and fetch special characters |
89dc6dfb BJ |
397 | */ |
398 | case TIOCSETC: | |
8062c8a7 | 399 | if (copyin(addr, (caddr_t)&tun, sizeof(struct tchars))) |
89dc6dfb BJ |
400 | u.u_error = EFAULT; |
401 | break; | |
402 | ||
403 | case TIOCGETC: | |
8062c8a7 BJ |
404 | if (copyout((caddr_t)&tun, addr, sizeof(struct tchars))) |
405 | u.u_error = EFAULT; | |
406 | break; | |
407 | ||
408 | /* local ioctls */ | |
50e2732b BJ |
409 | /* |
410 | * Set/get local special characters. | |
411 | */ | |
8062c8a7 BJ |
412 | case TIOCSLTC: |
413 | if (copyin(addr, (caddr_t)&tlun, sizeof (struct ltchars))) | |
414 | u.u_error = EFAULT; | |
415 | break; | |
416 | ||
417 | case TIOCGLTC: | |
418 | if (copyout((caddr_t)&tlun, addr, sizeof (struct ltchars))) | |
419 | u.u_error = EFAULT; | |
420 | break; | |
421 | ||
50e2732b BJ |
422 | /* |
423 | * Return number of characters immediately available. | |
424 | */ | |
8062c8a7 | 425 | case FIONREAD: { |
e1d74936 | 426 | off_t nread = ttnread(tp); |
8062c8a7 BJ |
427 | if (copyout((caddr_t)&nread, addr, sizeof (off_t))) |
428 | u.u_error = EFAULT; | |
429 | break; | |
430 | } | |
431 | ||
432 | /* | |
433 | * Should allow SPGRP and GPGRP only if tty open for reading. | |
434 | */ | |
435 | case TIOCSPGRP: | |
da1392b6 BJ |
436 | if (copyin(addr, (caddr_t)&tp->t_pgrp, sizeof (tp->t_pgrp))) |
437 | u.u_error = EFAULT; | |
8062c8a7 BJ |
438 | break; |
439 | ||
440 | case TIOCGPGRP: | |
441 | if (copyout((caddr_t)&tp->t_pgrp, addr, sizeof(tp->t_pgrp))) | |
442 | u.u_error = EFAULT; | |
443 | break; | |
444 | ||
445 | /* | |
446 | * Modify local mode word. | |
447 | */ | |
448 | case TIOCLBIS: | |
da1392b6 BJ |
449 | if (copyin(addr, (caddr_t)&temp, sizeof (tp->t_local))) |
450 | u.u_error = EFAULT; | |
451 | else | |
452 | tp->t_local |= temp; | |
8062c8a7 BJ |
453 | break; |
454 | ||
455 | case TIOCLBIC: | |
da1392b6 BJ |
456 | if (copyin(addr, (caddr_t)&temp, sizeof (tp->t_local))) |
457 | u.u_error = EFAULT; | |
458 | else | |
459 | tp->t_local &= ~temp; | |
8062c8a7 BJ |
460 | break; |
461 | ||
462 | case TIOCLSET: | |
da1392b6 BJ |
463 | if (copyin(addr, (caddr_t)&temp, sizeof (tp->t_local))) |
464 | u.u_error = EFAULT; | |
465 | else | |
466 | tp->t_local = temp; | |
8062c8a7 BJ |
467 | break; |
468 | ||
469 | case TIOCLGET: | |
470 | if (copyout((caddr_t)&tp->t_local, addr, sizeof(tp->t_local))) | |
89dc6dfb BJ |
471 | u.u_error = EFAULT; |
472 | break; | |
473 | ||
50e2732b BJ |
474 | /* |
475 | * Return number of characters in | |
476 | * the output. | |
477 | */ | |
0dde1c43 BJ |
478 | case TIOCOUTQ: |
479 | if (copyout((caddr_t)&tp->t_outq.c_cc, addr, sizeof(tp->t_outq.c_cc))) | |
480 | u.u_error = EFAULT; | |
481 | break; | |
482 | ||
50e2732b BJ |
483 | /* |
484 | * Simulate typing of a character at the terminal. | |
485 | */ | |
50450a20 BJ |
486 | case TIOCSTI: |
487 | c = fubyte(addr); | |
488 | if (u.u_uid && u.u_ttyp != tp || c < 0) | |
489 | u.u_error = EFAULT; | |
490 | else | |
491 | (*linesw[tp->t_line].l_rint)(c, tp); | |
492 | break; | |
bfcf09ee BJ |
493 | |
494 | case TIOCSTOP: | |
495 | c = spl5(); | |
496 | if ((tp->t_state & TS_TTSTOP) == 0) { | |
497 | tp->t_state |= TS_TTSTOP; | |
498 | (*cdevsw[major(tp->t_dev)].d_stop)(tp, 0); | |
499 | } | |
500 | splx(c); | |
501 | break; | |
502 | ||
503 | case TIOCSTART: | |
504 | c = spl5(); | |
505 | if ((tp->t_state & TS_TTSTOP) || (tp->t_local & LFLUSHO)) { | |
506 | tp->t_state &= ~TS_TTSTOP; | |
507 | tp->t_local &= ~LFLUSHO; | |
508 | ttstart(tp); | |
509 | } | |
510 | splx(c); | |
511 | break; | |
512 | ||
8062c8a7 | 513 | /* end of locals */ |
50450a20 | 514 | |
89dc6dfb BJ |
515 | default: |
516 | return(0); | |
517 | } | |
518 | return(1); | |
519 | } | |
e1d74936 BJ |
520 | |
521 | ttnread(tp) | |
522 | struct tty *tp; | |
523 | { | |
524 | int nread = 0; | |
525 | ||
526 | if (tp->t_local & LPENDIN) | |
527 | ttypend(tp); | |
528 | nread = tp->t_canq.c_cc; | |
529 | if (tp->t_flags & (RAW|CBREAK)) | |
530 | nread += tp->t_rawq.c_cc; | |
531 | return (nread); | |
532 | } | |
533 | ||
941944c9 | 534 | ttselect(dev, rw) |
e1d74936 | 535 | dev_t dev; |
941944c9 | 536 | int rw; |
e1d74936 BJ |
537 | { |
538 | register struct tty *tp = &cdevsw[major(dev)].d_ttys[minor(dev)]; | |
539 | int nread; | |
941944c9 | 540 | int s = spl5(); |
e1d74936 | 541 | |
941944c9 | 542 | switch (rw) { |
e1d74936 BJ |
543 | |
544 | case FREAD: | |
545 | nread = ttnread(tp); | |
546 | if (nread > 0) | |
941944c9 | 547 | goto win; |
89b8a44c | 548 | if (tp->t_rsel && tp->t_rsel->p_wchan == (caddr_t)&selwait) |
941944c9 | 549 | tp->t_state |= TS_RCOLL; |
e1d74936 BJ |
550 | else |
551 | tp->t_rsel = u.u_procp; | |
941944c9 | 552 | break; |
e1d74936 | 553 | |
941944c9 BJ |
554 | case FWRITE: |
555 | if (tp->t_outq.c_cc <= TTLOWAT(tp)) | |
556 | goto win; | |
941944c9 BJ |
557 | if (tp->t_wsel && tp->t_wsel->p_wchan == (caddr_t)&selwait) |
558 | tp->t_state |= TS_WCOLL; | |
559 | else | |
560 | tp->t_wsel = u.u_procp; | |
561 | break; | |
e1d74936 | 562 | } |
941944c9 BJ |
563 | splx(s); |
564 | return (0); | |
565 | win: | |
566 | splx(s); | |
567 | return (1); | |
e1d74936 | 568 | } |