tty.c (38434) | tty.c (41086) |
---|---|
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 * $Id: tty.c,v 1.105 1998/07/11 10:41:15 bde Exp $ | 39 * $Id: tty.c,v 1.106 1998/08/19 04:01:00 bde Exp $ |
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. --- 37 unchanged lines hidden (view full) --- 85#include <sys/conf.h> 86#include <sys/dkstat.h> 87#include <sys/poll.h> 88#include <sys/kernel.h> 89#include <sys/vnode.h> 90#include <sys/signalvar.h> 91#include <sys/resourcevar.h> 92#include <sys/malloc.h> | 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. --- 37 unchanged lines hidden (view full) --- 85#include <sys/conf.h> 86#include <sys/dkstat.h> 87#include <sys/poll.h> 88#include <sys/kernel.h> 89#include <sys/vnode.h> 90#include <sys/signalvar.h> 91#include <sys/resourcevar.h> 92#include <sys/malloc.h> |
93#include <sys/filedesc.h> |
|
93#if NSNP > 0 94#include <sys/snoop.h> 95#endif 96 97#include <vm/vm.h> 98#include <sys/lock.h> 99#include <vm/pmap.h> 100#include <vm/vm_map.h> --- 124 unchanged lines hidden (view full) --- 225 * the flush in case there are buggy callers. 226 */ 227int 228ttyclose(tp) 229 register struct tty *tp; 230{ 231 int s; 232 | 94#if NSNP > 0 95#include <sys/snoop.h> 96#endif 97 98#include <vm/vm.h> 99#include <sys/lock.h> 100#include <vm/pmap.h> 101#include <vm/vm_map.h> --- 124 unchanged lines hidden (view full) --- 226 * the flush in case there are buggy callers. 227 */ 228int 229ttyclose(tp) 230 register struct tty *tp; 231{ 232 int s; 233 |
234 funsetown(tp->t_sigio); |
|
233 s = spltty(); 234 if (constty == tp) 235 constty = NULL; 236 237 ttyflush(tp, FREAD | FWRITE); 238 clist_free_cblocks(&tp->t_canq); 239 clist_free_cblocks(&tp->t_outq); 240 clist_free_cblocks(&tp->t_rawq); --- 510 unchanged lines hidden (view full) --- 751 break; 752 case FIONBIO: /* set/clear non-blocking i/o */ 753 break; /* XXX: delete. */ 754 case FIONREAD: /* get # bytes to read */ 755 s = spltty(); 756 *(int *)data = ttnread(tp); 757 splx(s); 758 break; | 235 s = spltty(); 236 if (constty == tp) 237 constty = NULL; 238 239 ttyflush(tp, FREAD | FWRITE); 240 clist_free_cblocks(&tp->t_canq); 241 clist_free_cblocks(&tp->t_outq); 242 clist_free_cblocks(&tp->t_rawq); --- 510 unchanged lines hidden (view full) --- 753 break; 754 case FIONBIO: /* set/clear non-blocking i/o */ 755 break; /* XXX: delete. */ 756 case FIONREAD: /* get # bytes to read */ 757 s = spltty(); 758 *(int *)data = ttnread(tp); 759 splx(s); 760 break; |
761 762 case FIOSETOWN: 763 /* 764 * Policy -- Don't allow FIOSETOWN on someone else's 765 * controlling tty 766 */ 767 if (tp->t_session != NULL && !isctty(p, tp)) 768 return (ENOTTY); 769 770 error = fsetown(*(int *)data, &tp->t_sigio); 771 if (error) 772 return (error); 773 break; 774 case FIOGETOWN: 775 if (tp->t_session != NULL && !isctty(p, tp)) 776 return (ENOTTY); 777 *(int *)data = fgetown(tp->t_sigio); 778 break; 779 |
|
759 case TIOCEXCL: /* set exclusive use of tty */ 760 s = spltty(); 761 SET(tp->t_state, TS_XCLUDE); 762 splx(s); 763 break; 764 case TIOCFLUSH: { /* flush buffers */ 765 register int flags = *(int *)data; 766 --- 1310 unchanged lines hidden (view full) --- 2077 */ 2078void 2079ttwakeup(tp) 2080 register struct tty *tp; 2081{ 2082 2083 if (tp->t_rsel.si_pid != 0) 2084 selwakeup(&tp->t_rsel); | 780 case TIOCEXCL: /* set exclusive use of tty */ 781 s = spltty(); 782 SET(tp->t_state, TS_XCLUDE); 783 splx(s); 784 break; 785 case TIOCFLUSH: { /* flush buffers */ 786 register int flags = *(int *)data; 787 --- 1310 unchanged lines hidden (view full) --- 2098 */ 2099void 2100ttwakeup(tp) 2101 register struct tty *tp; 2102{ 2103 2104 if (tp->t_rsel.si_pid != 0) 2105 selwakeup(&tp->t_rsel); |
2085 if (ISSET(tp->t_state, TS_ASYNC)) 2086 pgsignal(tp->t_pgrp, SIGIO, 1); | 2106 if (ISSET(tp->t_state, TS_ASYNC) && tp->t_sigio != NULL) 2107 pgsigio(tp->t_sigio, SIGIO, (tp->t_session != NULL)); |
2087 wakeup(TSA_HUP_OR_INPUT(tp)); 2088} 2089 2090/* 2091 * Wake up any writers on a tty. 2092 */ 2093void 2094ttwwakeup(tp) --- 307 unchanged lines hidden --- | 2108 wakeup(TSA_HUP_OR_INPUT(tp)); 2109} 2110 2111/* 2112 * Wake up any writers on a tty. 2113 */ 2114void 2115ttwwakeup(tp) --- 307 unchanged lines hidden --- |