Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergiy Kuryata <sergeyk@microsoft.com>2017-05-10 23:46:20 +0300
committerGitHub <noreply@github.com>2017-05-10 23:46:20 +0300
commitd41bf46f2b32c68ee423334190caa6e616aafeb5 (patch)
tree9bd736959b1059249115b0ff98af251716e0a62c /src/Native/Runtime/unix
parent701fe3d160a73c13aeba96cff948f024f4335b09 (diff)
Configure the SIGPIPE signal to not terminate the process (#3576)
Diffstat (limited to 'src/Native/Runtime/unix')
-rw-r--r--src/Native/Runtime/unix/PalRedhawkUnix.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/Native/Runtime/unix/PalRedhawkUnix.cpp b/src/Native/Runtime/unix/PalRedhawkUnix.cpp
index e90895b36..998ea577a 100644
--- a/src/Native/Runtime/unix/PalRedhawkUnix.cpp
+++ b/src/Native/Runtime/unix/PalRedhawkUnix.cpp
@@ -34,6 +34,7 @@
#include <fcntl.h>
#include <sys/time.h>
#include <cstdarg>
+#include <signal.h>
#if HAVE_PTHREAD_GETTHREADID_NP
#include <pthread_np.h>
@@ -415,6 +416,19 @@ extern "C" int __cxa_thread_atexit(void (*)(void*), void*, void *);
extern "C" void *__dso_handle;
#endif
+// This functions configures behavior of the signals that are not
+// related to hardware exception handling.
+void ConfigureSignals()
+{
+ // The default action for SIGPIPE is process termination.
+ // Since SIGPIPE can be signaled when trying to write on a socket for which
+ // the connection has been dropped, we need to tell the system we want
+ // to ignore this signal.
+ // Instead of terminating the process, the system call which would had
+ // issued a SIGPIPE will, instead, report an error and set errno to EPIPE.
+ signal(SIGPIPE, SIG_IGN);
+}
+
// The Redhawk PAL must be initialized before any of its exports can be called. Returns true for a successful
// initialization and false on failure.
REDHAWK_PALEXPORT bool REDHAWK_PALAPI PalInit()
@@ -443,6 +457,8 @@ REDHAWK_PALEXPORT bool REDHAWK_PALAPI PalInit()
}
#endif // !USE_PORTABLE_HELPERS
+ ConfigureSignals();
+
return true;
}