]> sigrok.org Git - pulseview.git/commitdiff
Added error handling to SignalHandler
authorJoel Holdsworth <redacted>
Mon, 22 Apr 2013 20:43:00 +0000 (21:43 +0100)
committerJoel Holdsworth <redacted>
Mon, 22 Apr 2013 20:43:00 +0000 (21:43 +0100)
signalhandler.cpp

index f136a5234281038a4e4daec3fd61658193966f73..8c9244b3c269aa32992db7bce55af01e51f9229c 100644 (file)
 
 #include "signalhandler.h"
 
+#include <assert.h>
 #include <signal.h>
+#include <stdlib.h>
 #include <sys/socket.h>
 #include <unistd.h>
 
+#include <QDebug>
 #include <QSocketNotifier>
 
 int SignalHandler::_sockets[2];
@@ -63,7 +66,11 @@ void SignalHandler::on_socket_notifier_activated()
        _socket_notifier->setEnabled(false);
 
        int sig_number;
-       read(_sockets[1], &sig_number, sizeof(int));
+       if(read(_sockets[1], &sig_number, sizeof(int)) !=
+               sizeof(int)) {
+               qDebug() << "Failed to catch signal";
+               abort();
+       }
 
        switch(sig_number)
        {
@@ -80,5 +87,9 @@ void SignalHandler::on_socket_notifier_activated()
 
 void SignalHandler::handle_signals(int sig_number)
 {
-       write(_sockets[0], &sig_number, sizeof(int));
+       if(write(_sockets[0], &sig_number, sizeof(int)) !=
+               sizeof(int)) {
+               // Failed to handle signal
+               abort();
+       }
 }