From 39ceef4f3ff3d7872afd1236dc27ae94502c9e01 Mon Sep 17 00:00:00 2001
From: John Romein <romein@astron.nl>
Date: Wed, 17 Dec 2008 10:28:45 +0000
Subject: [PATCH] bug 225: Throw an exception if a system call fails.

---
 RTCP/IONProc/src/OutputThread.cc | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/RTCP/IONProc/src/OutputThread.cc b/RTCP/IONProc/src/OutputThread.cc
index c1fd18f8dae..748b61b7b3b 100644
--- a/RTCP/IONProc/src/OutputThread.cc
+++ b/RTCP/IONProc/src/OutputThread.cc
@@ -25,6 +25,7 @@
 
 #include <IONProc/OutputThread.h>
 #include <IONProc/ION_Allocator.h>
+#include <Stream/SystemCallException.h>
 
 
 namespace LOFAR {
@@ -38,19 +39,15 @@ OutputThread::OutputThread(Stream *streamToStorage, unsigned nrBaselines, unsign
   for (unsigned i = 0; i < maxSendQueueSize; i ++)
     itsFreeQueue.append(new CorrelatedData(nrBaselines, nrChannels, hugeMemoryAllocator));
 
-  if (pthread_create(&thread, 0, mainLoopStub, this) != 0) {
-    std::cerr << "could not create output thread" << std::endl;
-    exit(1);
-  }
+  if (pthread_create(&thread, 0, mainLoopStub, this) != 0)
+    throw SystemCallException("pthread_create output thread", errno, THROW_ARGS);
 }
 
 
 OutputThread::~OutputThread()
 {
-  if (pthread_join(thread, 0) != 0) {
-    std::cerr << "could not join output thread" << std::endl;
-    exit(1);
-  }
+  if (pthread_join(thread, 0) != 0)
+    throw SystemCallException("pthread_join output thread", errno, THROW_ARGS);
 
   while (!itsFreeQueue.empty())
     delete itsFreeQueue.remove();
-- 
GitLab