]> sigrok.org Git - pulseview.git/commitdiff
handle SIGUSR1 signal to run/stop the capture, UNIX only
authorMickael Bosch <redacted>
Fri, 9 Oct 2020 13:49:16 +0000 (15:49 +0200)
committerSoeren Apel <redacted>
Sun, 25 Oct 2020 20:47:05 +0000 (21:47 +0100)
main.cpp
pv/mainwindow.cpp
pv/mainwindow.hpp
signalhandler.cpp
signalhandler.hpp

index a307159c5005f92dfe26212e1c7f90fd1e7ca898..3a5ac29fc2bca41ae597f812ee90d88040b2a02f 100644 (file)
--- 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
index 3889d480fb0d12e1c2fd4cab880161e2de1c09be..4bf4f127cb9b91925711b72a1756764351160f6a 100644 (file)
@@ -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_);
index c9a8ad2641270d6d0df83f199b88d91939a2c675..5808a2f289c711d82f4a0fb08323674b499c3f97 100644 (file)
@@ -145,6 +145,9 @@ private Q_SLOTS:
 
        void on_close_current_tab();
 
+public Q_SLOTS:
+       void on_external_trigger();
+
 private:
        DeviceManager &device_manager_;
 
index 14706261b7d483bc0a031be43f82104549b6f5ca..d228718f00f8d861f8626d96e932c1b407e70fb0 100644 (file)
@@ -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);
index fad3ac39814d8b674829469e171ae315c20d04dd..0246dc991935a46457bd9e348105ac48ceca1710 100644 (file)
@@ -37,6 +37,7 @@ public:
 Q_SIGNALS:
        void int_received();
        void term_received();
+       void usr1_received();
 
 private Q_SLOTS:
        void on_socket_notifier_activated();