Project

General

Profile

Signal handling in art

The art process is configured to catch the following signals:

  • SIGQUIT
  • SIGTERM
  • SIGUSR2

In addition, SIGINT is trapped if the parameter services.scheduler.enableSigInt is set (defaults to true). Upon catching one of these signals, the handler sets a flag that will trigger art to terminate gracefully at the next opportunity, usually after the event currently being processed. However, if SIGINT (ctrl-C) is received while the system has a shutdown pending due to a previous signal, art will terminate immediately.

The default behavior if art shuts down successfully and exits on a signal is to produce an exit code of 128 plus the numeric value of the signal. If it is desired for the exit code to be 0 upon a successful shutdown of the art program that exits from a signal, then the --errorOnSIGINT program option can be set to false.

Root's signal handlers are disabled according to the parameter services.scheduler.unloadRootSigHandler (default true). If enabled, Root's trapping of the following signals is deactivated:

  • SIGCHILD
  • SIGBUS
  • SIGSEGV
  • SIGILL
  • SIGSYS
  • SIGPIPE
  • SIGALRM
  • SIGURG
  • SIGFPE
  • SIGWINCH

There is currently no facility to selectively disable ROOT signal handlers -- the disablement is all or nothing.

Signal handling by third-party applications.

In the case of a third party application invoking artapp (say) as a separate thread, the application should be careful to mask the artapp thread from handling signals (using e.g. pthread_sigmask prior to invoking the thread), and if an art shutdown is required, set art::shutdown_flag (art/Utilities/UnixSignalHandlers.h) to be the value of the signal received. As soon as it is able, the art thread will shut down. As of the time of writing, art::shutdown_flag is a volatile int, but may be changed e.g. to std::atomic<int> in future.