From 1e5e09563a4e3b6f094e2634c1453dd4d56e798c Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 24 Sep 2018 18:56:35 +0200 Subject: [PATCH] socket: Pass MSG_NOSIGNAL to send() This avoid that we get a SIGPIPE. Signed-off-by: Andreas Schneider --- src/socket.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/socket.c b/src/socket.c index d13f6ad3..2c72566d 100644 --- a/src/socket.c +++ b/src/socket.c @@ -589,13 +589,18 @@ static ssize_t ssh_socket_unbuffered_write(ssh_socket s, uint32_t len) { ssize_t w = -1; + int flags = 0; + +#ifdef MSG_NOSIGNAL + flags |= MSG_NOSIGNAL; +#endif if (s->data_except) { return -1; } if (s->fd_is_socket) { - w = send(s->fd_out,buffer, len, 0); + w = send(s->fd_out, buffer, len, flags); } else { w = write(s->fd_out, buffer, len); }