Steps to reproduce:
Actual output:
SignalValue: 0
Sending signal 2
SignalValue: 0
Expected output:
SignalValue: 0
Sending signal 2
SignalValue: 2
In XCode, create a new Command Line Tool Project.
Fill the main.cpp file with this code:
Code Block cpp #include <csignal> #include <iostream> namespace { volatile std::sig_atomic_t gSignalStatus; } void signal_handler(int signal) { gSignalStatus = signal; } int main() { // Install a signal handler std::signal(SIGINT, signal_handler); std::cout << "SignalValue: " << gSignalStatus << '\n'; std::cout << "Sending signal " << SIGINT << '\n'; std::raise(SIGINT); std::cout << "SignalValue: " << gSignalStatus << '\n'; }
Actual output:
SignalValue: 0
Sending signal 2
SignalValue: 0
Expected output:
SignalValue: 0
Sending signal 2
SignalValue: 2