Signal Handlers

WARNING The information on this page has not been updated in more than 10 years and significant parts of it are obsolete and no longer valid. It needs updating.

Complete: 3


Root includes a set of signal handlers that are activated by raising the corresponding system signal. An example of a signal is SIGSEGV, which corresponds to the dreaded segmentation violation. (For a complete list of the signals on a UNIX system, see man(7) signal.) Each signal has an associated piece of code, known as a handler, that is executed when that signal is raised. There are default handlers supplied by the operating system but the programmer may replace any default handler with a user-written custom version. The Root developers have chosen to do that so that, when you start up a Root session, the system default handlers are replaced by the custom handlers supplied by Root. These custom handlers have been known to cause problems from time to time. Hence it is occasionally useful to restore the system default handlers. This class gives the CMSSW user the ability to do that.

In addition, there is something called an error handler in Root. That piece of code serves as a central dispatcher for dealing with the multiple kinds of errors that can occur. Basically, the default Root error handler is given an error text and a severity level whenever some error occurs. The error text is printed out and computation continues or not depending on the reported severity of the error. The problem that arises here is that the error messages are directed to cerr and that causes an ugly interaction with the MessageLogger.

The SWGuideInitRootHandlers class also gives the CMSSW user the ability to switch to an alternate error handler that deals with this problem. It maps the Root defined error severity onto the set defined for the MessageLogger and then routes the message to the appropriate stream with calls to LogError, LogWarning or LogInfo as appropriate.

One of the main motivations for this is a side problem that some users have found very annoying. Due to a mismatch between CMSSW and some earlier Root releases, some users were being buried in error messages about missing dictionaries for certain Root classes. (TTreeIndex was a frequent offender.) By using the alternate error handler and routing the error message through the MessageLogger, the user can control these messages by tailoring the MessageLogger.cfg used.


The features of this class are controlled by the user through the configuration file for the job. If either

       include "FWCore/Service/data/InitRootHandlers.cfi"


       service = InitRootHandlers { }

appear in the config file, then both the alternate signal handlers and error handler is used. On the other hand, if the config file contains no mention of SWGuideInitRootHandlers, then the default (Root) handlers remain.

The user can take complete control of the choice of handlers with:

       service = InitRootHandlers  {
               untracked bool UnloadRootSigHandler = false
               untracked bool ResetRootErrHandler = true    }

which says to leave the default signal handler alone but use the alternate error handler.

The code for SWGuideInitRootHandlers was checked into the cvs repository on 22 Sept. 2006. The most recent release of CMSSW as of that date was CMSSW_1_1_0_pre2. Hence SWGuideInitRootHandlers is on the HEAD of the repository now and should become available in some subsequent release.

Review Status

Reviewer/Editor and Date (copy from screen) Comments
JohnMarraffino - 22 Sep 2006 page author
JennyWilliams - 31 Jan 2007 editing to include in SWGuide

Responsible: ChrisDJones
Last reviewed by: Reviewer

Edit | Attach | Watch | Print version | History: r8 < r7 < r6 < r5 < r4 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r8 - 2019-10-11 - DavidDagenhart

    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    CMSPublic All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback