socketpair: set SO_NOSIGPIPE where possible

Set SO_NOSIGPIPE on socketpair/inet-simulated socketpair
implementations. eventfd and pipe() do not need/want it.

Closes #20397
This commit is contained in:
Stefan Eissing 2026-01-22 11:46:46 +01:00 committed by Daniel Stenberg
parent ef3101d181
commit 2a6ae3684e
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
3 changed files with 35 additions and 9 deletions

View file

@ -109,10 +109,20 @@ static int wakeup_socketpair(curl_socket_t socks[2], bool nonblocking)
curlx_nonblock(socks[1], TRUE) < 0) {
sclose(socks[0]);
sclose(socks[1]);
socks[0] = socks[1] = CURL_SOCKET_BAD;
return -1;
}
}
#endif
#ifdef USE_SO_NOSIGPIPE
if(Curl_sock_nosigpipe(socks[1]) < 0) {
sclose(socks[0]);
sclose(socks[1]);
socks[0] = socks[1] = CURL_SOCKET_BAD;
return -1;
}
#endif /* USE_SO_NOSIGPIPE */
return 0;
}
@ -253,6 +263,10 @@ static int wakeup_inet(curl_socket_t socks[2], bool nonblocking)
if(curlx_nonblock(socks[0], TRUE) < 0 ||
curlx_nonblock(socks[1], TRUE) < 0)
goto error;
#ifdef USE_SO_NOSIGPIPE
if(Curl_sock_nosigpipe(socks[1]) < 0)
goto error;
#endif
sclose(listener);
return 0;
@ -260,6 +274,7 @@ error:
sclose(listener);
sclose(socks[0]);
sclose(socks[1]);
socks[0] = socks[1] = CURL_SOCKET_BAD;
return -1;
}