KSignalHandler Class

Header: #include <KSignalHandler>
CMake: find_package(KF6 REQUIRED COMPONENTS CoreAddons)
target_link_libraries(mytarget PRIVATE KF6::CoreAddons)
Since: 5.92
Inherits: QObject

Public Functions

void watchSignal(int signal)

Signals

void signalReceived(int signal)

Static Public Members

KSignalHandler *self()

Detailed Description

Allows getting ANSI C signals and forward them onto the Qt eventloop.

It's a singleton as it relies on static data getting defined.

{
  KSignalHandler::self()->watchSignal(SIGTERM);
  connect(KSignalHandler::self(), &KSignalHandler::signalReceived,
          this, &SomeClass::handleSignal);
  job->start();
}

Member Function Documentation

[static] KSignalHandler *KSignalHandler::self()

Fetches an instance we can use to register our signals.

[signal] void KSignalHandler::signalReceived(int signal)

Notifies that signal is emitted.

To catch a signal, we need to make sure it's registered using @m watchSignal.

See also watchSignal.

void KSignalHandler::watchSignal(int signal)

Adds signal to be watched for. Once the process is notified about this signal, @m signalReceived will be emitted with the same signal as an argument.

See also signalReceived.