From c95dc9d149b979da9557593b9cb3c9bfe00dc651 Mon Sep 17 00:00:00 2001 From: "Dustin J. Mitchell" Date: Sun, 22 Sep 2024 18:57:46 -0400 Subject: [PATCH] Ignore SIGPIPE (#3627) This replicates what the Rust runtime does, and matches what Rust code expects, for example when writing to a socket which is no longer connected to the remote end. --- src/main.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index cbdeb0994..b202cd6ad 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -39,6 +40,10 @@ int main(int argc, const char** argv) { int status{0}; + // Ignore SIGPIPE from writes to network sockets after the remote end has hung + // up. Rust code expects this, and the Rust runtime ignores this signal at startup. + signal(SIGPIPE, SIG_IGN); + Context globalContext; Context::setContext(&globalContext);