Don't raise SIGPIPE, let errno be set to EPIPE. i.e. this fixes slirp ethernet

mode with no listening port on the remote host.
This commit is contained in:
gbeauche 2007-11-03 11:31:36 +00:00
parent d7eb0f4d6d
commit b899d55068

View File

@ -47,6 +47,7 @@
#include <semaphore.h>
#include <errno.h>
#include <stdio.h>
#include <signal.h>
#include <map>
#if defined(__FreeBSD__) || defined(sgi) || (defined(__APPLE__) && defined(__MACH__))
@ -248,6 +249,16 @@ bool ether_init(void)
else
net_if_type = NET_IF_SHEEPNET;
// Don't raise SIGPIPE, let errno be set to EPIPE
struct sigaction sigpipe_sa;
if (sigaction(SIGPIPE, NULL, &sigpipe_sa) == 0) {
assert(sigpipe_sa.sa_handler == SIG_DFL || sigpipe_sa.sa_handler == SIG_IGN);
sigfillset(&sigpipe_sa.sa_mask);
sigpipe_sa.sa_flags = 0;
sigpipe_sa.sa_handler = SIG_IGN;
sigaction(SIGPIPE, &sigpipe_sa, NULL);
}
#ifdef HAVE_SLIRP
// Initialize slirp library
if (net_if_type == NET_IF_SLIRP) {