mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Fix socket send call on platforms without MSG_NOSIGNAL
To fix build issue encountered on MacOS Catalina but may apply to other platforms.
This commit is contained in:
parent
475bc29cc8
commit
6163bc392b
1 changed files with 9 additions and 0 deletions
|
|
@ -226,7 +226,11 @@ void socket_configure(void)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(SO_NOSIGPIPE) && !defined(MSG_NOSIGNAL)
|
||||||
|
if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR | SO_NOSIGPIPE, &optval, sizeof(optval)))
|
||||||
|
#else
|
||||||
if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)))
|
if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)))
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
tio_error_printf("Failed to set socket options (%s)", strerror(errno));
|
tio_error_printf("Failed to set socket options (%s)", strerror(errno));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
@ -270,7 +274,12 @@ void socket_write(char input_char)
|
||||||
{
|
{
|
||||||
if (clientfds[i] != -1)
|
if (clientfds[i] != -1)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#if defined(SO_NOSIGPIPE) && !defined(MSG_NOSIGNAL)
|
||||||
|
if (send(clientfds[i], &input_char, 1, 0) <= 0)
|
||||||
|
#else
|
||||||
if (send(clientfds[i], &input_char, 1, MSG_NOSIGNAL) <= 0)
|
if (send(clientfds[i], &input_char, 1, MSG_NOSIGNAL) <= 0)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
tio_error_printf_silent("Failed to write to socket (%s)", strerror(errno));
|
tio_error_printf_silent("Failed to write to socket (%s)", strerror(errno));
|
||||||
close(clientfds[i]);
|
close(clientfds[i]);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue