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.4 (Berkeley) 2/20/95 |
34 * $FreeBSD: head/sys/kern/tty_pty.c 91140 2002-02-23 11:12:57Z tanimura $ |
35 */ 36 37/* 38 * Pseudo-teletype Driver 39 * (Actually two drivers, requiring two entries in 'cdevsw') 40 */ 41#include "opt_compat.h" 42#include <sys/param.h> 43#include <sys/systm.h> |
44#include <sys/lock.h> 45#include <sys/mutex.h> 46#include <sys/sx.h> |
47#if defined(COMPAT_43) || defined(COMPAT_SUNOS) 48#include <sys/ioctl_compat.h> 49#endif 50#include <sys/proc.h> 51#include <sys/tty.h> 52#include <sys/conf.h> 53#include <sys/fcntl.h> 54#include <sys/poll.h> --- 180 unchanged lines hidden (view full) --- 235 struct proc *p = td->td_proc; 236 register struct tty *tp = dev->si_tty; 237 register struct pt_ioctl *pti = dev->si_drv1; 238 int error = 0; 239 240again: 241 if (pti->pt_flags & PF_REMOTE) { 242 while (isbackground(p, tp)) { |
243 PGRPSESS_SLOCK(); 244 PROC_LOCK(p); |
245 if (SIGISMEMBER(p->p_sigignore, SIGTTIN) || 246 SIGISMEMBER(p->p_sigmask, SIGTTIN) || |
247 p->p_pgrp->pg_jobc == 0 || p->p_flag & P_PPWAIT) { 248 PROC_UNLOCK(p); |
249 return (EIO); |
250 } 251 PROC_UNLOCK(p); 252 PGRP_LOCK(p->p_pgrp); 253 PGRPSESS_SUNLOCK(); |
254 pgsignal(p->p_pgrp, SIGTTIN, 1); |
255 PGRP_UNLOCK(p->p_pgrp); |
256 error = ttysleep(tp, &lbolt, TTIPRI | PCATCH, "ptsbg", 257 0); 258 if (error) 259 return (error); 260 } 261 if (tp->t_canq.c_cc == 0) { 262 if (flag & IO_NDELAY) 263 return (EWOULDBLOCK); --- 457 unchanged lines hidden (view full) --- 721 break; 722 723 case TIOCSIG: 724 if (*(unsigned int *)data >= NSIG || 725 *(unsigned int *)data == 0) 726 return(EINVAL); 727 if ((tp->t_lflag&NOFLSH) == 0) 728 ttyflush(tp, FREAD|FWRITE); |
729 if (tp->t_pgrp != NULL) { 730 PGRP_LOCK(tp->t_pgrp); 731 pgsignal(tp->t_pgrp, *(unsigned int *)data, 1); 732 PGRP_UNLOCK(tp->t_pgrp); 733 } |
734 if ((*(unsigned int *)data == SIGINFO) && 735 ((tp->t_lflag&NOKERNINFO) == 0)) 736 ttyinfo(tp); 737 return(0); 738 } 739 } 740 if (cmd == TIOCEXT) { 741 /* --- 132 unchanged lines hidden --- |