From: Mickael Bosch Date: Fri, 9 Oct 2020 13:49:16 +0000 (+0200) Subject: handle SIGUSR1 signal to run/stop the capture, UNIX only X-Git-Url: http://sigrok.org/gitweb/?p=pulseview.git;a=commitdiff_plain;h=f1e9295aa5b9ff538c30b7c799a9c6b0efbfca3b handle SIGUSR1 signal to run/stop the capture, UNIX only --- diff --git a/main.cpp b/main.cpp index a307159c..3a5ac29f 100644 --- a/main.cpp +++ b/main.cpp @@ -350,10 +350,9 @@ int main(int argc, char *argv[]) #ifdef ENABLE_SIGNALS if (SignalHandler::prepare_signals()) { SignalHandler *const handler = new SignalHandler(&w); - QObject::connect(handler, SIGNAL(int_received()), - &w, SLOT(close())); - QObject::connect(handler, SIGNAL(term_received()), - &w, SLOT(close())); + QObject::connect(handler, SIGNAL(int_received()), &w, SLOT(close())); + QObject::connect(handler, SIGNAL(term_received()), &w, SLOT(close())); + QObject::connect(handler, SIGNAL(usr1_received()), &w, SLOT(on_run_stop_clicked())); } else qWarning() << "Could not prepare signal handler."; #endif diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index 3889d480..4bf4f127 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -728,6 +728,11 @@ void MainWindow::on_run_stop_clicked() } } +void MainWindow::on_external_trigger() +{ + on_run_stop_clicked(); +} + void MainWindow::on_settings_clicked() { dialogs::Settings dlg(device_manager_); diff --git a/pv/mainwindow.hpp b/pv/mainwindow.hpp index c9a8ad26..5808a2f2 100644 --- a/pv/mainwindow.hpp +++ b/pv/mainwindow.hpp @@ -145,6 +145,9 @@ private Q_SLOTS: void on_close_current_tab(); +public Q_SLOTS: + void on_external_trigger(); + private: DeviceManager &device_manager_; diff --git a/signalhandler.cpp b/signalhandler.cpp index 14706261..d228718f 100644 --- a/signalhandler.cpp +++ b/signalhandler.cpp @@ -43,7 +43,8 @@ bool SignalHandler::prepare_signals() sig_action.sa_flags = SA_RESTART; if (sigaction(SIGINT, &sig_action, nullptr) != 0 || - sigaction(SIGTERM, &sig_action, nullptr) != 0) { + sigaction(SIGTERM, &sig_action, nullptr) != 0 || + sigaction(SIGUSR1, &sig_action, nullptr) != 0) { close(sockets_[0]); close(sockets_[1]); return false; @@ -78,6 +79,9 @@ void SignalHandler::on_socket_notifier_activated() case SIGTERM: Q_EMIT term_received(); break; + case SIGUSR1: + Q_EMIT usr1_received(); + break; } socket_notifier_->setEnabled(true); diff --git a/signalhandler.hpp b/signalhandler.hpp index fad3ac39..0246dc99 100644 --- a/signalhandler.hpp +++ b/signalhandler.hpp @@ -37,6 +37,7 @@ public: Q_SIGNALS: void int_received(); void term_received(); + void usr1_received(); private Q_SLOTS: void on_socket_notifier_activated();