mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-22 20:55:16 +00:00
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:
@@ -23,6 +23,7 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <csignal>
|
||||||
|
|
||||||
#if defined(__linux__) || defined(__LINUX__)
|
#if defined(__linux__) || defined(__LINUX__)
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
@@ -7459,6 +7460,13 @@ extern "C" {
|
|||||||
#else /* _MSC_VER */
|
#else /* _MSC_VER */
|
||||||
int main(int argc, char **argv)
|
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);
|
return CLI().run(argc, argv);
|
||||||
}
|
}
|
||||||
#endif /* _MSC_VER */
|
#endif /* _MSC_VER */
|
||||||
|
|||||||
Reference in New Issue
Block a user