ignore SIGPIPE

this prevents a crash on clients improperly closing sockets
This commit is contained in:
xfnw 2021-11-16 16:16:57 -05:00
parent d968844f65
commit 0df4eebd91

View file

@ -7,6 +7,7 @@
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/syscall.h> #include <sys/syscall.h>
#include <sys/signal.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <arpa/inet.h> #include <arpa/inet.h>
@ -95,6 +96,8 @@ void *handle_connection(void *socket_desc) {
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
int port; int port;
signal(SIGPIPE, SIG_IGN);
port = argc > 1 ? atoi(argv[1]) : 0; port = argc > 1 ? atoi(argv[1]) : 0;
if (!port) if (!port)
port = 1234; port = 1234;