From 5b5295b8eba286ada5f259144674df88b51bd21e Mon Sep 17 00:00:00 2001
From: Marcel Loose <loose@astron.nl>
Date: Thu, 16 Jan 2014 13:49:27 +0000
Subject: [PATCH] Task #5395: Reverted commit r27942; it breaks tMPITransfer,
 which now gets killed by SIGALRM. Maybe the test needs fixing, though. I
 cannot judge.

---
 RTCP/Cobalt/InputProc/src/OMPThread.h | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/RTCP/Cobalt/InputProc/src/OMPThread.h b/RTCP/Cobalt/InputProc/src/OMPThread.h
index 5877d1da78c..067628eea92 100644
--- a/RTCP/Cobalt/InputProc/src/OMPThread.h
+++ b/RTCP/Cobalt/InputProc/src/OMPThread.h
@@ -71,9 +71,8 @@ namespace LOFAR
     void kill()
     {
       while (!stopped) {
-        // Interrupt blocking system calls (most notably, read()),
-        // possibly multiple in a row.
-        // Note that the thread will stick around until the end
+        // interrupt blocking system calls (most notably, read())
+        // 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;
@@ -113,16 +112,8 @@ namespace LOFAR
 
     static void init()
     {
-      // We avoid cancellation exception for OpenMP threads.
-      // Allow signalling them ourselves to cancel blocking syscalls.
-      struct sigaction sa;
-      sa.sa_handler = sighandler;
-      ::sigemptyset(&sa.sa_mask);
-      sa.sa_flags = SA_RESTART;
-      int err = ::sigaction(SIGHUP, &sa, NULL);
-      if (err != 0) {
-        LOG_WARN("Failed to register a handler for SIGHUP: OpenMP threads may not terminate!");
-      }
+      signal(SIGHUP, sighandler);
+      siginterrupt(SIGHUP, 1);
     }
 
   private:
-- 
GitLab