diff options
| -rw-r--r-- | fs/pipe.c | 6 | ||||
| -rw-r--r-- | include/linux/fs.h | 1 | ||||
| -rw-r--r-- | include/uapi/linux/fs.h | 5 | ||||
| -rw-r--r-- | net/socket.c | 3 | 
4 files changed, 12 insertions, 3 deletions
| diff --git a/fs/pipe.c b/fs/pipe.c index 731622d0738d..42fead1efe52 100644 --- a/fs/pipe.c +++ b/fs/pipe.c @@ -458,7 +458,8 @@ anon_pipe_write(struct kiocb *iocb, struct iov_iter *from)  	mutex_lock(&pipe->mutex);  	if (!pipe->readers) { -		send_sig(SIGPIPE, current, 0); +		if ((iocb->ki_flags & IOCB_NOSIGNAL) == 0) +			send_sig(SIGPIPE, current, 0);  		ret = -EPIPE;  		goto out;  	} @@ -498,7 +499,8 @@ anon_pipe_write(struct kiocb *iocb, struct iov_iter *from)  	for (;;) {  		if (!pipe->readers) { -			send_sig(SIGPIPE, current, 0); +			if ((iocb->ki_flags & IOCB_NOSIGNAL) == 0) +				send_sig(SIGPIPE, current, 0);  			if (!ret)  				ret = -EPIPE;  			break; diff --git a/include/linux/fs.h b/include/linux/fs.h index 780e9c774c54..34693cae15a2 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -356,6 +356,7 @@ struct readahead_control;  #define IOCB_APPEND		(__force int) RWF_APPEND  #define IOCB_ATOMIC		(__force int) RWF_ATOMIC  #define IOCB_DONTCACHE		(__force int) RWF_DONTCACHE +#define IOCB_NOSIGNAL		(__force int) RWF_NOSIGNAL  /* non-RWF related bits - start at 16 */  #define IOCB_EVENTFD		(1 << 16) diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h index 0bd678a4a10e..beb4c2d1e41c 100644 --- a/include/uapi/linux/fs.h +++ b/include/uapi/linux/fs.h @@ -430,10 +430,13 @@ typedef int __bitwise __kernel_rwf_t;  /* buffered IO that drops the cache after reading or writing data */  #define RWF_DONTCACHE	((__force __kernel_rwf_t)0x00000080) +/* prevent pipe and socket writes from raising SIGPIPE */ +#define RWF_NOSIGNAL	((__force __kernel_rwf_t)0x00000100) +  /* mask of flags supported by the kernel */  #define RWF_SUPPORTED	(RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT |\  			 RWF_APPEND | RWF_NOAPPEND | RWF_ATOMIC |\ -			 RWF_DONTCACHE) +			 RWF_DONTCACHE | RWF_NOSIGNAL)  #define PROCFS_IOCTL_MAGIC 'f' diff --git a/net/socket.c b/net/socket.c index 682969deaed3..bac335ecee4c 100644 --- a/net/socket.c +++ b/net/socket.c @@ -1176,6 +1176,9 @@ static ssize_t sock_write_iter(struct kiocb *iocb, struct iov_iter *from)  	if (sock->type == SOCK_SEQPACKET)  		msg.msg_flags |= MSG_EOR; +	if (iocb->ki_flags & IOCB_NOSIGNAL) +		msg.msg_flags |= MSG_NOSIGNAL; +  	res = __sock_sendmsg(sock, &msg);  	*from = msg.msg_iter;  	return res; | 
