From 44b49a3eaabb1d905f97eb9095f7d07ef42f5081 Mon Sep 17 00:00:00 2001 From: jhb Date: Tue, 29 Jun 2010 20:44:19 +0000 Subject: [PATCH] Send SIGPIPE to the thread that issued the offending system call rather than to the entire process. Reported by: Anit Chakraborty Reviewed by: kib, deischen (concept) MFC after: 1 week --- sys/kern/sys_generic.c | 2 +- sys/kern/sys_socket.c | 2 +- sys/kern/uipc_syscalls.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c index 293dbb1b46cd..a1a7086dd030 100644 --- a/sys/kern/sys_generic.c +++ b/sys/kern/sys_generic.c @@ -532,7 +532,7 @@ dofilewrite(td, fd, fp, auio, offset, flags) /* Socket layer is responsible for issuing SIGPIPE. */ if (fp->f_type != DTYPE_SOCKET && error == EPIPE) { PROC_LOCK(td->td_proc); - psignal(td->td_proc, SIGPIPE); + tdsignal(td, SIGPIPE); PROC_UNLOCK(td->td_proc); } } diff --git a/sys/kern/sys_socket.c b/sys/kern/sys_socket.c index 717ef3e8ccf1..2766ca429305 100644 --- a/sys/kern/sys_socket.c +++ b/sys/kern/sys_socket.c @@ -102,7 +102,7 @@ soo_write(struct file *fp, struct uio *uio, struct ucred *active_cred, error = sosend(so, 0, uio, 0, 0, 0, uio->uio_td); if (error == EPIPE && (so->so_options & SO_NOSIGPIPE) == 0) { PROC_LOCK(uio->uio_td->td_proc); - psignal(uio->uio_td->td_proc, SIGPIPE); + tdsignal(uio->uio_td, SIGPIPE); PROC_UNLOCK(uio->uio_td->td_proc); } return (error); diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index 6585e83cf7d3..3165dab5c550 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -794,7 +794,7 @@ kern_sendit(td, s, mp, flags, control, segflg) if (error == EPIPE && !(so->so_options & SO_NOSIGPIPE) && !(flags & MSG_NOSIGNAL)) { PROC_LOCK(td->td_proc); - psignal(td->td_proc, SIGPIPE); + tdsignal(td, SIGPIPE); PROC_UNLOCK(td->td_proc); } } @@ -2444,7 +2444,7 @@ sctp_generic_sendmsg (td, uap) if (error == EPIPE && !(so->so_options & SO_NOSIGPIPE) && !(uap->flags & MSG_NOSIGNAL)) { PROC_LOCK(td->td_proc); - psignal(td->td_proc, SIGPIPE); + tdsignal(td, SIGPIPE); PROC_UNLOCK(td->td_proc); } } @@ -2562,7 +2562,7 @@ sctp_generic_sendmsg_iov(td, uap) if (error == EPIPE && !(so->so_options & SO_NOSIGPIPE) && !(uap->flags & MSG_NOSIGNAL)) { PROC_LOCK(td->td_proc); - psignal(td->td_proc, SIGPIPE); + tdsignal(td, SIGPIPE); PROC_UNLOCK(td->td_proc); } }