diff options
author | Vishwa Pravin <lordvishwa123@gmail.com> | 2023-04-03 12:16:33 +0530 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2023-04-06 13:41:53 +1000 |
commit | f309b3f6087db6c83126f8f227f1fc4984cf24b1 (patch) | |
tree | 6d293d5a48a3172a684c3e482d0bce164718b69c /demos | |
parent | f06ef1657a3d4322153b26231a7afa3d55724e52 (diff) | |
download | openssl-f309b3f6087db6c83126f8f227f1fc4984cf24b1.tar.gz |
Ignore SIGPIPE if client closes connection abruptly
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20678)
Diffstat (limited to 'demos')
-rw-r--r-- | demos/sslecho/main.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/demos/sslecho/main.c b/demos/sslecho/main.c index 0233794c4e..ca430046c4 100644 --- a/demos/sslecho/main.c +++ b/demos/sslecho/main.c @@ -14,6 +14,7 @@ #include <arpa/inet.h> #include <openssl/ssl.h> #include <openssl/err.h> +#include <signal.h> static const int server_port = 4433; @@ -151,6 +152,9 @@ int main(int argc, char **argv) struct sockaddr_in addr; unsigned int addr_len = sizeof(addr); + /* ignore SIGPIPE so that server can continue running when client pipe closes abruptly */ + signal(SIGPIPE, SIG_IGN); + /* Splash */ printf("\nsslecho : Simple Echo Client/Server (OpenSSL 3.0.1-dev) : %s : %s\n\n", __DATE__, __TIME__); @@ -218,6 +222,8 @@ int main(int argc, char **argv) if ((rxlen = SSL_read(ssl, rxbuf, rxcap)) <= 0) { if (rxlen == 0) { printf("Client closed connection\n"); + } else { + printf("SSL_read returned %d\n", rxlen); } ERR_print_errors_fp(stderr); break; |