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.
This commit is contained in:
Dustin J. Mitchell 2024-09-22 18:57:46 -04:00 committed by GitHub
parent d75ef7f197
commit c95dc9d149
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -29,6 +29,7 @@
#include <Context.h>
#include <rust/cxx.h>
#include <signal.h>
#include <cstring>
#include <iostream>
@ -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);