comparison util.c @ 1973:cd163b230cf9

Fix handling of remote disconnects
author Michael Pavone <pavone@retrodev.com>
date Fri, 08 May 2020 15:17:47 -0700
parents 417e0fc958cc
children 441d5d6cea2f
comparison
equal deleted inserted replaced
1972:f2d37131840e 1973:cd163b230cf9
724 return WSAGetLastError() == WSAEWOULDBLOCK; 724 return WSAGetLastError() == WSAEWOULDBLOCK;
725 } 725 }
726 726
727 #else 727 #else
728 #include <fcntl.h> 728 #include <fcntl.h>
729 #include <signal.h>
729 730
730 void socket_init(void) 731 void socket_init(void)
731 { 732 {
733 //SIGPIPE on network sockets is not desired
734 //would be better to do this in a more limited way,
735 //but the alternatives are not portable
736 signal(SIGPIPE, SIG_IGN);
732 } 737 }
733 738
734 int socket_blocking(int sock, int should_block) 739 int socket_blocking(int sock, int should_block)
735 { 740 {
736 if (fcntl(sock, F_SETFL, should_block ? 0 : O_NONBLOCK)) { 741 if (fcntl(sock, F_SETFL, should_block ? 0 : O_NONBLOCK)) {