Skip to content

Commit

Permalink
Ignore SIGPIPE (#3627)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
djmitche authored Sep 22, 2024
1 parent d75ef7f commit c95dc9d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#include <Context.h>
#include <rust/cxx.h>
#include <signal.h>

#include <cstring>
#include <iostream>
Expand All @@ -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);

Expand Down

0 comments on commit c95dc9d

Please sign in to comment.