aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-02-20 18:34:18 +0000
committerNick Mathewson <nickm@torproject.org>2007-02-20 18:34:18 +0000
commitb6e6b7101b43040632d3d171ec465086ea188f44 (patch)
tree90b12990c3dbcc66c5c82824f127869bd5117f3c /src/common
parent986d0ac39bcc4d21b4878eb5249d501820ed9534 (diff)
downloadtor-b6e6b7101b43040632d3d171ec465086ea188f44.tar.gz
tor-b6e6b7101b43040632d3d171ec465086ea188f44.zip
r11850@catbus: nickm | 2007-02-20 13:34:13 -0500
Apply patch from coderman: have posix subthreads mask out signals. This could prevent some kinds of crashes when subthreads try to handle SIGPIPEs and die in the attempt. Backport candidate. svn:r9603
Diffstat (limited to 'src/common')
-rw-r--r--src/common/compat.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/common/compat.c b/src/common/compat.c
index d9df8892a5..b06ac414b0 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -82,6 +82,9 @@ const char compat_c_id[] =
#ifdef HAVE_PTHREAD_H
#include <pthread.h>
#endif
+#ifdef HAVE_SIGNAL_H
+#include <signal.h>
+#endif
#ifdef HAVE_UTIME_H
#include <utime.h>
#endif
@@ -996,6 +999,12 @@ tor_pthread_helper_fn(void *_data)
tor_pthread_data_t *data = _data;
void (*func)(void*);
void *arg;
+ /* mask signals to worker threads to avoid SIGPIPE, etc */
+ sigset_t sigs;
+ /* We're in a subthread; don't handle any signals here. */
+ sigfillset(&sigs);
+ pthread_sigmask(SIG_SETMASK, &sigs, NULL);
+
func = data->func;
arg = data->data;
tor_free(_data);