From d4aa7d1f55a740b8127cb90e99a874fbb41f17a6 Mon Sep 17 00:00:00 2001 From: Alexander van Amesfoort <amesfoort@astron.nl> Date: Mon, 20 Jan 2014 15:11:45 +0000 Subject: [PATCH] Task #5395: re-commit signal()/siginterrupt() patch to replace them with sigaction(), now without SA_RESTART flag (duh). tMPITransfer is not broken by this patch version. --- RTCP/Cobalt/InputProc/src/OMPThread.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/RTCP/Cobalt/InputProc/src/OMPThread.h b/RTCP/Cobalt/InputProc/src/OMPThread.h index 067628eea92..0cb93313112 100644 --- a/RTCP/Cobalt/InputProc/src/OMPThread.h +++ b/RTCP/Cobalt/InputProc/src/OMPThread.h @@ -71,8 +71,9 @@ namespace LOFAR void kill() { while (!stopped) { - // interrupt blocking system calls (most notably, read()) - // note that the thread will stick around until the end + // Interrupt blocking system calls (most notably, read()), + // possibly multiple in a row. + // Note that the thread will stick around until the end // of pragma parallel, so the thread id is always valid // once it has been set. pthread_t oldid = id; @@ -112,8 +113,16 @@ namespace LOFAR static void init() { - signal(SIGHUP, sighandler); - siginterrupt(SIGHUP, 1); + // We avoid cancellation exception for OpenMP threads. + // Allow signalling them ourselves to interrupt some blocking syscalls. + struct sigaction sa; + sa.sa_handler = sighandler; + ::sigemptyset(&sa.sa_mask); + sa.sa_flags = 0; + int err = ::sigaction(SIGHUP, &sa, NULL); + if (err != 0) { + LOG_WARN("Failed to register a handler for SIGHUP: OpenMP threads may not terminate!"); + } } private: -- GitLab