c++ - Catch shutdown console in Linux -
I want to capture a user shutdown in the Linux terminal, such as:
< Code> sudo shutdown
I am using the following C ++ code:
myAct.sa_handler = myStructure :: mySignalHandler; Signigation (my signal, and act, null);
And I'm using a script to send a mySignal
signal.
However, using a script means to modify the system's main files, and I do not want it.
Is there another way to capture shutdown signals in Linux through the C ++ code?
According to the man page, when the shutdown is run, all processes send a cigarette. So if you write your signal handler for SIGTERM, then you do not need to include any other script.
Comments
Post a Comment