From: Joel Holdsworth Date: Mon, 22 Apr 2013 20:43:00 +0000 (+0100) Subject: Added error handling to SignalHandler X-Git-Tag: pulseview-0.1.0~26 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=70c0818c7c7787963712bb1135c01b727d1ca474;p=pulseview.git Added error handling to SignalHandler --- diff --git a/signalhandler.cpp b/signalhandler.cpp index f136a523..8c9244b3 100644 --- a/signalhandler.cpp +++ b/signalhandler.cpp @@ -20,10 +20,13 @@ #include "signalhandler.h" +#include #include +#include #include #include +#include #include 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(); + } }