Ignore SIGPIPE at startup to prevent crashes on dropped printer connections (#13788)

Ignore SIGPIPE at startup to prevent crash on dropped printer connection

Writing to a closed printer network socket raised SIGPIPE, whose default
action terminated the whole process (exit 141, no crash report). Set
SIGPIPE to SIG_IGN once at main() entry (POSIX only) so such writes return
EPIPE to the existing networking error handling instead of killing the app.

Fixes #13787
This commit is contained in:
Zuhaib Siddique
2026-05-22 07:18:53 -07:00
committed by GitHub
parent 464ca4c765
commit ffde56ccba

View File

@@ -23,6 +23,7 @@
#include <cstring>
#include <iostream>
#include <math.h>
#include <csignal>
#if defined(__linux__) || defined(__LINUX__)
#include <condition_variable>
@@ -7459,6 +7460,13 @@ extern "C" {
#else /* _MSC_VER */
int main(int argc, char **argv)
{
#ifndef _WIN32
// Ignore SIGPIPE so a write to a closed socket (e.g. a dropped printer
// network connection) returns EPIPE to the caller instead of terminating
// the whole process. Without this, losing the printer link kills
// OrcaSlicer with SIGPIPE (exit 141) and produces no crash report.
std::signal(SIGPIPE, SIG_IGN);
#endif
return CLI().run(argc, argv);
}
#endif /* _MSC_VER */