I need to catch any OS shut down and execute some actions before letting the OS be shutted down. I'm using Fedora 19 and C++.
I'm able to catch a shutdown signal given by the console with the following C++ code :
myAct.sa_handler = myStructure::mySignalHandler;
sigaction(mySignal, &act, NULL);
The mySignal
signal can be activated via /etc/init.d
and a custom code executed before a shutdown is made.
On Fedora 12 Kernel 2.6, this solutions works perfectly. The solution works on Fedora 19 Kernel 3.9.5 if I try to shut down the computer using the graphic interface.
However, I can't manage to execute my code when a command is used in a terminal to reboot or shut down the computer on Fedora 19 kernel 3.9.5
The solution doesn't work anymore since it dropped the usual init.d
script system.
Putting my script on the /usr/lib/systemsd
location doesn't work, the script is executed, but the other scripts are also executed. Thus, the systems shuts down not treating my commands.
How may I solve that problem?