namespace alps { namespace scheduler { class SignalHandler { public: enum SignalInfo { NOSIGNAL, USER1, USER2, STOP, TERMINATE }; SignalHandler(); SignalInfo operator()(); static void stopprocess(); }; } }
The first time an object of type SignalHandler is constructed, it installs functions to catch the signals SIGINT, SIGQUIT, SIGTERM, SIGTSTP, SIGUSR1 and SIGUSR2 if they exist on the operating system. These signal handler remain installed until the program terminates. Any SignalHandler object allows inquiry about signal caught. Note that at the moment this is not thread-safe.SignalHandler();
To ensure independence from the operating system the signals get mapped to type SignalInfo. The standard mapping on Unix-like operating systems is:enum SignalInfo { NOSIGNAL, USER1, USER2, STOP, TERMINATE };
Signal | SignalInfo |
SIGINT | TERMINATE |
SIGQUIT | TERMINATE |
SIGTERM | TERMINATE |
SIGTSTP | STOP |
SIGUSR1 | USER1 |
SIGUSR2 | USER2 |
returns a caught signal or NOSIGNAL if no signal was caught. If more than one signal was caught the signal with highest priority is returned first, where the priority decreases as USER1 > USER2 > STOP > TERMINATE. This allows user signals to be processed before the process is stopped or interrupted.SignalInfo operator()();
send its own process a noncatchable stop signal. This is useful to actually stop the process after intercepting a stop signal.static void stopprocess();
copyright (c) 1994-2010 by Matthias Troyer
Distributed under the Boost Software License, Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt)