diff options
author | Don Lewis <truckman@FreeBSD.org> | 1998-11-11 10:04:13 +0000 |
---|---|---|
committer | Don Lewis <truckman@FreeBSD.org> | 1998-11-11 10:04:13 +0000 |
commit | 831d27a9f56da38cf007714c169d208e7b9739be (patch) | |
tree | 2bce7c99fd05ca07a117966c4c41f2f544ef20f3 /sys/kern | |
parent | 21ffb6774a08602e1208977da6c5a652d85d32b6 (diff) |
Notes
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_descrip.c | 142 | ||||
-rw-r--r-- | sys/kern/kern_exit.c | 8 | ||||
-rw-r--r-- | sys/kern/kern_proc.c | 10 | ||||
-rw-r--r-- | sys/kern/kern_sig.c | 39 | ||||
-rw-r--r-- | sys/kern/subr_log.c | 30 | ||||
-rw-r--r-- | sys/kern/sys_generic.c | 33 | ||||
-rw-r--r-- | sys/kern/sys_pipe.c | 26 | ||||
-rw-r--r-- | sys/kern/sys_socket.c | 15 | ||||
-rw-r--r-- | sys/kern/tty.c | 27 | ||||
-rw-r--r-- | sys/kern/uipc_sockbuf.c | 14 | ||||
-rw-r--r-- | sys/kern/uipc_socket.c | 9 | ||||
-rw-r--r-- | sys/kern/uipc_socket2.c | 14 |
12 files changed, 259 insertions, 108 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index e3d736b417b4..d2ef3e17f09e 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)kern_descrip.c 8.6 (Berkeley) 4/19/94 - * $Id: kern_descrip.c,v 1.54 1998/07/15 06:10:16 bde Exp $ + * $Id: kern_descrip.c,v 1.55 1998/07/29 17:38:13 bde Exp $ */ #include "opt_compat.h" @@ -71,6 +71,7 @@ static MALLOC_DEFINE(M_FILEDESC, "file desc", "Open file descriptor table"); MALLOC_DEFINE(M_FILE, "file", "Open file structure"); +static MALLOC_DEFINE(M_SIGIO, "sigio", "sigio structures"); static d_open_t fdopen; @@ -257,30 +258,13 @@ fcntl(p, uap) return (error); case F_GETOWN: - if (fp->f_type == DTYPE_SOCKET) { - p->p_retval[0] = ((struct socket *)fp->f_data)->so_pgid; - return (0); - } error = (*fp->f_ops->fo_ioctl) - (fp, TIOCGPGRP, (caddr_t)p->p_retval, p); - p->p_retval[0] = - p->p_retval[0]; + (fp, FIOGETOWN, (caddr_t)p->p_retval, p); return (error); case F_SETOWN: - if (fp->f_type == DTYPE_SOCKET) { - ((struct socket *)fp->f_data)->so_pgid = uap->arg; - return (0); - } - if (uap->arg <= 0) { - uap->arg = -uap->arg; - } else { - struct proc *p1 = pfind(uap->arg); - if (p1 == 0) - return (ESRCH); - uap->arg = p1->p_pgrp->pg_id; - } return ((*fp->f_ops->fo_ioctl) - (fp, TIOCSPGRP, (caddr_t)&uap->arg, p)); + (fp, FIOSETOWN, (caddr_t)&uap->arg, p)); case F_SETLKW: flg |= F_WAIT; @@ -366,6 +350,124 @@ finishdup(fdp, old, new, retval) } /* + * If sigio is on the list associated with a process or process group, + * disable signalling from the device, remove sigio from the list and + * free sigio. + */ +void +funsetown(sigio) + struct sigio *sigio; +{ + int s; + + if (sigio == NULL) + return; + s = splhigh(); + *(sigio->sio_myref) = NULL; + splx(s); + if (sigio->sio_pgid < 0) { + SLIST_REMOVE(&sigio->sio_pgrp->pg_sigiolst, sigio, + sigio, sio_pgsigio); + } else /* if ((*sigiop)->sio_pgid > 0) */ { + SLIST_REMOVE(&sigio->sio_proc->p_sigiolst, sigio, + sigio, sio_pgsigio); + } + crfree(sigio->sio_ucred); + FREE(sigio, M_SIGIO); +} + +/* Free a list of sigio structures. */ +void +funsetownlst(sigiolst) + struct sigiolst *sigiolst; +{ + struct sigio *sigio; + + while ((sigio = sigiolst->slh_first) != NULL) + funsetown(sigio); +} + +/* + * This is common code for FIOSETOWN ioctl called by fcntl(fd, F_SETOWN, arg). + * + * After permission checking, add a sigio structure to the sigio list for + * the process or process group. + */ +int +fsetown(pgid, sigiop) + pid_t pgid; + struct sigio **sigiop; +{ + struct proc *proc = NULL; + struct pgrp *pgrp = NULL; + struct sigio *sigio; + int s; + + if (pgid == 0) { + funsetown(*sigiop); + return (0); + } else if (pgid > 0) { + proc = pfind(pgid); + if (proc == NULL) + return (ESRCH); + /* + * Policy - Don't allow a process to FSETOWN a process + * in another session. + * + * Remove this test to allow maximum flexibility or + * restrict FSETOWN to the current process or process + * group for maximum safety. + */ + else if (proc->p_session != curproc->p_session) + return (EPERM); + } else /* if (pgid < 0) */ { + pgrp = pgfind(-pgid); + if (pgrp == NULL) + return (ESRCH); + /* + * Policy - Don't allow a process to FSETOWN a process + * in another session. + * + * Remove this test to allow maximum flexibility or + * restrict FSETOWN to the current process or process + * group for maximum safety. + */ + else if (pgrp->pg_session != curproc->p_session) + return (EPERM); + } + funsetown(*sigiop); + MALLOC(sigio, struct sigio *, sizeof(struct sigio), M_SIGIO, + M_WAITOK); + if (pgid > 0) { + SLIST_INSERT_HEAD(&proc->p_sigiolst, sigio, sio_pgsigio); + sigio->sio_proc = proc; + } else { + SLIST_INSERT_HEAD(&pgrp->pg_sigiolst, sigio, sio_pgsigio); + sigio->sio_pgrp = pgrp; + } + sigio->sio_pgid = pgid; + crhold(curproc->p_ucred); + sigio->sio_ucred = curproc->p_ucred; + /* It would be convenient if p_ruid was in ucred. */ + sigio->sio_ruid = curproc->p_cred->p_ruid; + sigio->sio_myref = sigiop; + s = splhigh(); + *sigiop = sigio; + splx(s); + return (0); +} + +/* + * This is common code for FIOGETOWN ioctl called by fcntl(fd, F_GETOWN, arg). + */ +pid_t +fgetown(sigio) + struct sigio *sigio; +{ + return (sigio != NULL ? sigio->sio_pgid : 0); +} + +/* * Close a file descriptor. */ #ifndef _SYS_SYSPROTO_H_ diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 84ae1a1d2dd3..fd5e23ef7189 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)kern_exit.c 8.7 (Berkeley) 2/12/94 - * $Id: kern_exit.c,v 1.67 1998/06/05 21:44:20 dg Exp $ + * $Id: kern_exit.c,v 1.68 1998/11/10 09:16:29 peter Exp $ */ #include "opt_compat.h" @@ -187,6 +187,12 @@ exit1(p, rv) untimeout(realitexpire, (caddr_t)p, p->p_ithandle); /* + * Reset any sigio structures pointing to us as a result of + * F_SETOWN with our pid. + */ + funsetownlst(&p->p_sigiolst); + + /* * Close open files and release open-file table. * This may block! */ diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index d546ad771911..a51735880943 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)kern_proc.c 8.7 (Berkeley) 2/14/95 - * $Id: kern_proc.c,v 1.37 1998/07/11 07:45:40 bde Exp $ + * $Id: kern_proc.c,v 1.38 1998/11/09 15:07:41 truckman Exp $ */ #include <sys/param.h> @@ -48,6 +48,7 @@ #include <vm/vm_map.h> #include <sys/user.h> #include <vm/vm_zone.h> +#include <sys/filedesc.h> static MALLOC_DEFINE(M_PGRP, "pgrp", "process group header"); MALLOC_DEFINE(M_SESSION, "session", "session header"); @@ -243,6 +244,7 @@ enterpgrp(p, pgid, mksess) LIST_INIT(&pgrp->pg_members); LIST_INSERT_HEAD(PGRPHASH(pgid), pgrp, pg_hash); pgrp->pg_jobc = 0; + SLIST_INIT(&pgrp->pg_sigiolst); } else if (pgrp == p->p_pgrp) return (0); @@ -285,6 +287,12 @@ pgdelete(pgrp) register struct pgrp *pgrp; { + /* + * Reset any sigio structures pointing to us as a result of + * F_SETOWN with our pgid. + */ + funsetownlst(&pgrp->pg_sigiolst); + if (pgrp->pg_session->s_ttyp != NULL && pgrp->pg_session->s_ttyp->t_pgrp == pgrp) pgrp->pg_session->s_ttyp->t_pgrp = NULL; diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 290917ac4a10..29baceed4afb 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)kern_sig.c 8.7 (Berkeley) 4/18/94 - * $Id: kern_sig.c,v 1.47 1998/09/14 23:25:18 jdp Exp $ + * $Id: kern_sig.c,v 1.48 1998/10/21 16:31:38 jdp Exp $ */ #include "opt_compat.h" @@ -86,6 +86,16 @@ SYSCTL_INT(_kern, KERN_LOGSIGEXIT, logsigexit, CTLFLAG_RW, &kern_logsigexit, 0, (pc)->pc_ucred->cr_uid == (q)->p_ucred->cr_uid || \ ((signum) == SIGCONT && (q)->p_session == (p)->p_session)) +/* + * Policy -- Can real uid ruid with ucred uc send a signal to process q? + */ +#define CANSIGIO(ruid, uc, q) \ + ((uc)->cr_uid == 0 || \ + (ruid) == (q)->p_cred->p_ruid || \ + (uc)->cr_uid == (q)->p_cred->p_ruid || \ + (ruid) == (q)->p_ucred->cr_uid || \ + (uc)->cr_uid == (q)->p_ucred->cr_uid) + int sugid_coredump; SYSCTL_INT(_kern, OID_AUTO, sugid_coredump, CTLFLAG_RW, &sugid_coredump, 0, ""); @@ -1344,3 +1354,30 @@ nosys(p, args) psignal(p, SIGSYS); return (EINVAL); } + +/* + * Send a signal to a SIGIO or SIGURG to a process or process group using + * stored credentials rather than those of the current process. + */ +void +pgsigio(sigio, signum, checkctty) + struct sigio *sigio; + int signum, checkctty; +{ + if (sigio == NULL) + return; + + if (sigio->sio_pgid > 0) { + if (CANSIGIO(sigio->sio_ruid, sigio->sio_ucred, + sigio->sio_proc)) + psignal(sigio->sio_proc, signum); + } else if (sigio->sio_pgid < 0) { + struct proc *p; + + for (p = sigio->sio_pgrp->pg_members.lh_first; p != NULL; + p = p->p_pglist.le_next) + if (CANSIGIO(sigio->sio_ruid, sigio->sio_ucred, p) && + (checkctty == 0 || (p->p_flag & P_CONTROLT))) + psignal(p, signum); + } +} diff --git a/sys/kern/subr_log.c b/sys/kern/subr_log.c index 80193d400743..01d8c4eb6a06 100644 --- a/sys/kern/subr_log.c +++ b/sys/kern/subr_log.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)subr_log.c 8.1 (Berkeley) 6/10/93 - * $Id: subr_log.c,v 1.29 1998/05/28 09:30:20 phk Exp $ + * $Id: subr_log.c,v 1.30 1998/06/07 17:11:38 dfr Exp $ */ /* @@ -51,6 +51,7 @@ #include <sys/signalvar.h> #include <sys/kernel.h> #include <sys/poll.h> +#include <sys/filedesc.h> #ifdef DEVFS #include <sys/devfsext.h> #endif /*DEVFS*/ @@ -75,7 +76,7 @@ static struct cdevsw log_cdevsw = static struct logsoftc { int sc_state; /* see above for possibilities */ struct selinfo sc_selp; /* process waiting on select call */ - int sc_pgid; /* process/group for async I/O */ + struct sigio *sc_sigio; /* information for SIGIO */ } logsoftc; int log_open; /* also used in log() */ @@ -90,7 +91,7 @@ logopen(dev, flags, mode, p) if (log_open) return (EBUSY); log_open = 1; - logsoftc.sc_pgid = p->p_pid; /* signal process only */ + fsetown(p->p_pid, &logsoftc.sc_sigio); /* signal process only */ return (0); } @@ -104,6 +105,7 @@ logclose(dev, flag, mode, p) log_open = 0; logsoftc.sc_state = 0; + funsetown(logsoftc.sc_sigio); return (0); } @@ -183,12 +185,8 @@ logwakeup() if (!log_open) return; selwakeup(&logsoftc.sc_selp); - if (logsoftc.sc_state & LOG_ASYNC) { - if (logsoftc.sc_pgid < 0) - gsignal(-logsoftc.sc_pgid, SIGIO); - else if ((p = pfind(logsoftc.sc_pgid))) - psignal(p, SIGIO); - } + if ((logsoftc.sc_state & LOG_ASYNC) && logsoftc.sc_sigio != NULL) + pgsigio(logsoftc.sc_sigio, SIGIO, 0); if (logsoftc.sc_state & LOG_RDWAIT) { wakeup((caddr_t)msgbufp); logsoftc.sc_state &= ~LOG_RDWAIT; @@ -229,12 +227,20 @@ logioctl(dev, com, data, flag, p) logsoftc.sc_state &= ~LOG_ASYNC; break; - case TIOCSPGRP: - logsoftc.sc_pgid = *(int *)data; + case FIOSETOWN: + return (fsetown(*(int *)data, &logsoftc.sc_sigio)); + + case FIOGETOWN: + *(int *)data = fgetown(logsoftc.sc_sigio); break; + /* This is deprecated, FIOSETOWN should be used instead. */ + case TIOCSPGRP: + return (fsetown(-(*(int *)data), &logsoftc.sc_sigio)); + + /* This is deprecated, FIOGETOWN should be used instead */ case TIOCGPGRP: - *(int *)data = logsoftc.sc_pgid; + *(int *)data = -fgetown(logsoftc.sc_sigio); break; default: diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c index bb8f7a3a70b0..e16fed7cfbd6 100644 --- a/sys/kern/sys_generic.c +++ b/sys/kern/sys_generic.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)sys_generic.c 8.5 (Berkeley) 1/21/94 - * $Id: sys_generic.c,v 1.40 1998/08/24 08:39:38 dfr Exp $ + * $Id: sys_generic.c,v 1.41 1998/09/05 14:30:11 bde Exp $ */ #include "opt_ktrace.h" @@ -469,37 +469,6 @@ ioctl(p, uap) error = (*fp->f_ops->fo_ioctl)(fp, FIOASYNC, (caddr_t)&tmp, p); break; - case FIOSETOWN: - tmp = *(int *)data; - if (fp->f_type == DTYPE_SOCKET) { - ((struct socket *)fp->f_data)->so_pgid = tmp; - error = 0; - break; - } - if (tmp <= 0) { - tmp = -tmp; - } else { - struct proc *p1 = pfind(tmp); - if (p1 == 0) { - error = ESRCH; - break; - } - tmp = p1->p_pgrp->pg_id; - } - error = (*fp->f_ops->fo_ioctl) - (fp, (int)TIOCSPGRP, (caddr_t)&tmp, p); - break; - - case FIOGETOWN: - if (fp->f_type == DTYPE_SOCKET) { - error = 0; - *(int *)data = ((struct socket *)fp->f_data)->so_pgid; - break; - } - error = (*fp->f_ops->fo_ioctl)(fp, (int)TIOCGPGRP, data, p); - *(int *)data = -*(int *)data; - break; - default: error = (*fp->f_ops->fo_ioctl)(fp, com, data, p); /* diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c index 5f6789752c28..b95cdd28e078 100644 --- a/sys/kern/sys_pipe.c +++ b/sys/kern/sys_pipe.c @@ -16,7 +16,7 @@ * 4. Modifications may be freely made to this file if the above conditions * are met. * - * $Id: sys_pipe.c,v 1.43 1998/10/13 08:24:40 dg Exp $ + * $Id: sys_pipe.c,v 1.44 1998/10/28 13:36:58 dg Exp $ */ /* @@ -256,7 +256,6 @@ pipeinit(cpipe) cpipe->pipe_atime = cpipe->pipe_ctime; cpipe->pipe_mtime = cpipe->pipe_ctime; bzero(&cpipe->pipe_sel, sizeof cpipe->pipe_sel); - cpipe->pipe_pgid = NO_PID; #ifndef PIPE_NODIRECT /* @@ -315,12 +314,8 @@ pipeselwakeup(cpipe) cpipe->pipe_state &= ~PIPE_SEL; selwakeup(&cpipe->pipe_sel); } - if (cpipe->pipe_state & PIPE_ASYNC) { - if (cpipe->pipe_pgid < 0) - gsignal(-cpipe->pipe_pgid, SIGIO); - else if ((p = pfind(cpipe->pipe_pgid)) != NULL) - psignal(p, SIGIO); - } + if ((cpipe->pipe_state & PIPE_ASYNC) && cpipe->pipe_sigio) + pgsigio(cpipe->pipe_sigio, SIGIO, 0); } /* ARGSUSED */ @@ -953,12 +948,20 @@ pipe_ioctl(fp, cmd, data, p) *(int *)data = mpipe->pipe_buffer.cnt; return (0); - case TIOCSPGRP: - mpipe->pipe_pgid = *(int *)data; + case FIOSETOWN: + return (fsetown(*(int *)data, &mpipe->pipe_sigio)); + + case FIOGETOWN: + *(int *)data = fgetown(mpipe->pipe_sigio); return (0); + /* This is deprecated, FIOSETOWN should be used instead. */ + case TIOCSPGRP: + return (fsetown(-(*(int *)data), &mpipe->pipe_sigio)); + + /* This is deprecated, FIOGETOWN should be used instead. */ case TIOCGPGRP: - *(int *)data = mpipe->pipe_pgid; + *(int *)data = -fgetown(mpipe->pipe_sigio); return (0); } @@ -1038,6 +1041,7 @@ pipe_close(fp, p) { struct pipe *cpipe = (struct pipe *)fp->f_data; + funsetown(cpipe->pipe_sigio); pipeclose(cpipe); fp->f_data = NULL; return 0; diff --git a/sys/kern/sys_socket.c b/sys/kern/sys_socket.c index 5b65bea89362..8cf30cdcaf55 100644 --- a/sys/kern/sys_socket.c +++ b/sys/kern/sys_socket.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)sys_socket.c 8.1 (Berkeley) 6/10/93 - * $Id: sys_socket.c,v 1.17 1998/03/28 10:33:07 bde Exp $ + * $Id: sys_socket.c,v 1.18 1998/06/07 17:11:40 dfr Exp $ */ #include <sys/param.h> @@ -44,6 +44,7 @@ #include <sys/sockio.h> #include <sys/stat.h> #include <sys/uio.h> +#include <sys/filedesc.h> #include <net/if.h> #include <net/route.h> @@ -114,12 +115,18 @@ soo_ioctl(fp, cmd, data, p) *(int *)data = so->so_rcv.sb_cc; return (0); - case SIOCSPGRP: - so->so_pgid = *(int *)data; + case FIOSETOWN: + return (fsetown(*(int *)data, &so->so_sigio)); + + case FIOGETOWN: + *(int *)data = fgetown(so->so_sigio); return (0); + case SIOCSPGRP: + return (fsetown(-(*(int *)data), &so->so_sigio)); + case SIOCGPGRP: - *(int *)data = so->so_pgid; + *(int *)data = -fgetown(so->so_sigio); return (0); case SIOCATMARK: diff --git a/sys/kern/tty.c b/sys/kern/tty.c index 7d34873e2e4d..8a043fd215a8 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)tty.c 8.8 (Berkeley) 1/21/94 - * $Id: tty.c,v 1.105 1998/07/11 10:41:15 bde Exp $ + * $Id: tty.c,v 1.106 1998/08/19 04:01:00 bde Exp $ */ /*- @@ -90,6 +90,7 @@ #include <sys/signalvar.h> #include <sys/resourcevar.h> #include <sys/malloc.h> +#include <sys/filedesc.h> #if NSNP > 0 #include <sys/snoop.h> #endif @@ -230,6 +231,7 @@ ttyclose(tp) { int s; + funsetown(tp->t_sigio); s = spltty(); if (constty == tp) constty = NULL; @@ -756,6 +758,25 @@ ttioctl(tp, cmd, data, flag) *(int *)data = ttnread(tp); splx(s); break; + + case FIOSETOWN: + /* + * Policy -- Don't allow FIOSETOWN on someone else's + * controlling tty + */ + if (tp->t_session != NULL && !isctty(p, tp)) + return (ENOTTY); + + error = fsetown(*(int *)data, &tp->t_sigio); + if (error) + return (error); + break; + case FIOGETOWN: + if (tp->t_session != NULL && !isctty(p, tp)) + return (ENOTTY); + *(int *)data = fgetown(tp->t_sigio); + break; + case TIOCEXCL: /* set exclusive use of tty */ s = spltty(); SET(tp->t_state, TS_XCLUDE); @@ -2082,8 +2103,8 @@ ttwakeup(tp) if (tp->t_rsel.si_pid != 0) selwakeup(&tp->t_rsel); - if (ISSET(tp->t_state, TS_ASYNC)) - pgsignal(tp->t_pgrp, SIGIO, 1); + if (ISSET(tp->t_state, TS_ASYNC) && tp->t_sigio != NULL) + pgsigio(tp->t_sigio, SIGIO, (tp->t_session != NULL)); wakeup(TSA_HUP_OR_INPUT(tp)); } diff --git a/sys/kern/uipc_sockbuf.c b/sys/kern/uipc_sockbuf.c index 23c7751776e7..6c55ca0fff42 100644 --- a/sys/kern/uipc_sockbuf.c +++ b/sys/kern/uipc_sockbuf.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)uipc_socket2.c 8.1 (Berkeley) 6/10/93 - * $Id: uipc_socket2.c,v 1.39 1998/09/05 13:24:39 bde Exp $ + * $Id: uipc_socket2.c,v 1.40 1998/11/04 20:22:11 fenner Exp $ */ #include <sys/param.h> @@ -213,7 +213,7 @@ sonewconn(head, connstatus) so->so_state = head->so_state | SS_NOFDREF; so->so_proto = head->so_proto; so->so_timeo = head->so_timeo; - so->so_pgid = head->so_pgid; + fsetown(fgetown(head->so_sigio), &so->so_sigio); so->so_uid = head->so_uid; (void) soreserve(so, head->so_snd.sb_hiwat, head->so_rcv.sb_hiwat); @@ -321,12 +321,8 @@ sowakeup(so, sb) sb->sb_flags &= ~SB_WAIT; wakeup((caddr_t)&sb->sb_cc); } - if (so->so_state & SS_ASYNC) { - if (so->so_pgid < 0) - gsignal(-so->so_pgid, SIGIO); - else if (so->so_pgid > 0 && (p = pfind(so->so_pgid)) != 0) - psignal(p, SIGIO); - } + if ((so->so_state & SS_ASYNC) && so->so_sigio != NULL) + pgsigio(so->so_sigio, SIGIO, 0); if (sb->sb_flags & SB_UPCALL) (*so->so_upcall)(so, so->so_upcallarg, M_DONTWAIT); } @@ -918,7 +914,7 @@ sotoxsocket(struct socket *so, struct xsocket *xso) xso->so_qlimit = so->so_qlimit; xso->so_timeo = so->so_timeo; xso->so_error = so->so_error; - xso->so_pgid = so->so_pgid; + xso->so_pgid = so->so_sigio ? so->so_sigio->sio_pgid : 0; xso->so_oobmark = so->so_oobmark; sbtoxsockbuf(&so->so_snd, &xso->so_snd); sbtoxsockbuf(&so->so_rcv, &xso->so_rcv); diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 05d312f65302..275e94b44bc0 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)uipc_socket.c 8.3 (Berkeley) 4/15/94 - * $Id: uipc_socket.c,v 1.44 1998/08/31 15:34:55 wollman Exp $ + * $Id: uipc_socket.c,v 1.45 1998/08/31 18:07:23 wollman Exp $ */ #include <sys/param.h> @@ -218,6 +218,7 @@ soclose(so) int s = splnet(); /* conservative */ int error = 0; + funsetown(so->so_sigio); if (so->so_options & SO_ACCEPTCONN) { struct socket *sp, *sonext; @@ -1182,10 +1183,8 @@ sohasoutofband(so) { struct proc *p; - if (so->so_pgid < 0) - gsignal(-so->so_pgid, SIGURG); - else if (so->so_pgid > 0 && (p = pfind(so->so_pgid)) != 0) - psignal(p, SIGURG); + if (so->so_sigio != NULL) + pgsigio(so->so_sigio, SIGURG, 0); selwakeup(&so->so_rcv.sb_sel); } diff --git a/sys/kern/uipc_socket2.c b/sys/kern/uipc_socket2.c index 23c7751776e7..6c55ca0fff42 100644 --- a/sys/kern/uipc_socket2.c +++ b/sys/kern/uipc_socket2.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)uipc_socket2.c 8.1 (Berkeley) 6/10/93 - * $Id: uipc_socket2.c,v 1.39 1998/09/05 13:24:39 bde Exp $ + * $Id: uipc_socket2.c,v 1.40 1998/11/04 20:22:11 fenner Exp $ */ #include <sys/param.h> @@ -213,7 +213,7 @@ sonewconn(head, connstatus) so->so_state = head->so_state | SS_NOFDREF; so->so_proto = head->so_proto; so->so_timeo = head->so_timeo; - so->so_pgid = head->so_pgid; + fsetown(fgetown(head->so_sigio), &so->so_sigio); so->so_uid = head->so_uid; (void) soreserve(so, head->so_snd.sb_hiwat, head->so_rcv.sb_hiwat); @@ -321,12 +321,8 @@ sowakeup(so, sb) sb->sb_flags &= ~SB_WAIT; wakeup((caddr_t)&sb->sb_cc); } - if (so->so_state & SS_ASYNC) { - if (so->so_pgid < 0) - gsignal(-so->so_pgid, SIGIO); - else if (so->so_pgid > 0 && (p = pfind(so->so_pgid)) != 0) - psignal(p, SIGIO); - } + if ((so->so_state & SS_ASYNC) && so->so_sigio != NULL) + pgsigio(so->so_sigio, SIGIO, 0); if (sb->sb_flags & SB_UPCALL) (*so->so_upcall)(so, so->so_upcallarg, M_DONTWAIT); } @@ -918,7 +914,7 @@ sotoxsocket(struct socket *so, struct xsocket *xso) xso->so_qlimit = so->so_qlimit; xso->so_timeo = so->so_timeo; xso->so_error = so->so_error; - xso->so_pgid = so->so_pgid; + xso->so_pgid = so->so_sigio ? so->so_sigio->sio_pgid : 0; xso->so_oobmark = so->so_oobmark; sbtoxsockbuf(&so->so_snd, &xso->so_snd); sbtoxsockbuf(&so->so_rcv, &xso->so_rcv); |