Skip to content

Commit

Permalink
Sockets: Ignore SIGPIPE on Linux
Browse files Browse the repository at this point in the history
Stops our process terminating if the socket is disconnected
mid-write.
  • Loading branch information
stenzek committed Jul 21, 2024
1 parent 14d8760 commit 6b78364
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/util/platform_misc_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,29 @@
#include "input_manager.h"
#include "platform_misc.h"

#include "common/error.h"
#include "common/log.h"
#include "common/path.h"
#include "common/scoped_guard.h"
#include "common/small_string.h"

#include <cinttypes>
#include <dbus/dbus.h>
#include <signal.h>
#include <spawn.h>
#include <unistd.h>

Log_SetChannel(PlatformMisc);

bool PlatformMisc::InitializeSocketSupport(Error* error)
{
// Ignore SIGPIPE, we handle errors ourselves.
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
{
Error::SetErrno(error, "signal(SIGPIPE, SIG_IGN) failed: ", errno);
return false;
}

return true;
}

Expand Down

0 comments on commit 6b78364

Please sign in to comment.