mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-06-18 06: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 "CustomAssert.h"
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
#include "Startup.h"
|
#include "Startup.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <thread>
|
#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(){
|
[[noreturn]] void loop(){
|
||||||
DebugPrintTID();
|
DebugPrintTID();
|
||||||
@@ -15,6 +28,11 @@
|
|||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
try {
|
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();
|
DebugPrintTID();
|
||||||
// curl needs to be initialized to properly deallocate its resources later
|
// curl needs to be initialized to properly deallocate its resources later
|
||||||
Assert(curl_global_init(CURL_GLOBAL_DEFAULT) == CURLE_OK);
|
Assert(curl_global_init(CURL_GLOBAL_DEFAULT) == CURLE_OK);
|
||||||
|
|||||||
Reference in New Issue
Block a user