mirror of
https://github.com/SantaSpeen/BeamMP-Server.git
synced 2026-06-19 10:30:53 +00:00
Ignore SIGPIPE so we dont crash on broken pipes
This commit is contained in:
+19
-1
@@ -1,9 +1,22 @@
|
||||
|
||||
#include "CustomAssert.h"
|
||||
#include <curl/curl.h>
|
||||
#include "Startup.h"
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
#include "Security/Xor.h"
|
||||
#ifndef WIN32
|
||||
#include <signal.h>
|
||||
void UnixSignalHandler(int sig) {
|
||||
switch (sig) {
|
||||
case SIGPIPE:
|
||||
warn(Sec("ignored signal SIGPIPE: Pipe broken"));
|
||||
break;
|
||||
default:
|
||||
error(Sec("Signal arrived in handler but was not handled: ") + std::to_string(sig));
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif // WIN32
|
||||
|
||||
[[noreturn]] void loop(){
|
||||
DebugPrintTID();
|
||||
@@ -15,6 +28,11 @@
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
try {
|
||||
#ifndef WIN32
|
||||
// ignore SIGPIPE, the signal that is sent for example when a client
|
||||
// disconnects while data is being sent to him ("broken pipe").
|
||||
signal(SIGPIPE, UnixSignalHandler);
|
||||
#endif // WIN32
|
||||
DebugPrintTID();
|
||||
// curl needs to be initialized to properly deallocate its resources later
|
||||
Assert(curl_global_init(CURL_GLOBAL_DEFAULT) == CURLE_OK);
|
||||
|
||||
Reference in New Issue
Block a user