server - Ignored SIGPIPE (fixes crashes if the client quits unexpectedly)
authorJohn Hodge <[email protected]>
Mon, 28 Feb 2011 03:02:50 +0000 (11:02 +0800)
committerJohn Hodge <[email protected]>
Mon, 28 Feb 2011 03:02:50 +0000 (11:02 +0800)
src/server/server.c

index fa50f0d..79a5c2d 100644 (file)
@@ -17,6 +17,7 @@
 #include <string.h>
 #include <limits.h>
 #include <stdarg.h>
 #include <string.h>
 #include <limits.h>
 #include <stdarg.h>
+#include <signal.h>
 
 #define        DEBUG_TRACE_CLIENT      0
 
 
 #define        DEBUG_TRACE_CLIENT      0
 
@@ -119,6 +120,8 @@ void Server_Start(void)
        struct sockaddr_in      server_addr, client_addr;
 
        atexit(Server_Cleanup);
        struct sockaddr_in      server_addr, client_addr;
 
        atexit(Server_Cleanup);
+       // Ignore SIGPIPE (stops crashes when the client exits early)
+       signal(SIGPIPE, SIG_IGN);
 
        // Create Server
        giServer_Socket = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
 
        // Create Server
        giServer_Socket = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);

UCC git Repository :: git.ucc.asn.au