Re: Catching a signal

From: Filimon Roukoutakis <Filimon.Roukoutakis_at_cern.ch>
Date: Wed, 26 Jan 2011 17:36:57 +0100


Unfortunately TApplication::SetSignalHandler is protected in ROOT 5.28 and for a number of reasons I cannot make my application inherit from it (which would normally work) since I have to follow a different hierarchy. I will try to see whether I can do the equivalent with GetListOfSignalHandlers then if there is no other solution. Thanks, filimon

On 01/26/2011 05:16 PM, Fons Rademakers wrote:
> Hi,
>
> use TApplication::GetSignalHandler() to get the current interrupt
> handler. Do something like:
>
> TSignalHandler *ih = gApplication->GetSignalHandler();
> ih->Remove();
> MyInterruptHandler *my = new MyInterruptHandler();
> my->Add();
> gApplication->SetSignalHandler(my);
> delete ih;
>
> Cheers, Fons.
>
>
> On 26/01/2011 16:38, Filimon Roukoutakis wrote:
>> Hi, my signal hanlder gets called after the normal Rint handler is
>> called
>> (the usual *** Break *** keyboard interrupt (tmpfile):1:) and then on
>> all
>> subsequent ctrl-c is not called, only the familiar one above. Is this
>> the
>> expected behaviour? I would expect that my handler completely
>> replaces the
>> existing one. Is it possible to achieve this somehow?
>> TSystem::RemoveSignalHandler
>> <http://root.cern.ch/root/html/TSystem.html#TSystem:RemoveSignalHandler>()
>>
>> would require the original object (not in my scope) and searching
>> through
>> TSystem::GetListOfSignalHandlers
>> <http://root.cern.ch/root/html/TSystem.html#TSystem:GetListOfSignalHandlers>()
>>
>> seems a little bit cumbersome. Any hints? cheers,
>> filimon
>>
>> On 01/26/2011 03:30 PM, Philippe Canal wrote:
>>> Hi,
>>>
>>> See TInterruptHandler in core/rint/src/TRint.cxx and
>>> core/rint/src/TRint.h
>>> and use gSystem->SetSignalHandler.
>>>
>>> Cheers,
>>> Philippe
>>>
>>> On 1/26/11 8:15 AM, Filimon Roukoutakis wrote:
>>>> Hi, I would like to catch ctrl-C while my long loop is running under a
>>>> ROOT session and then terminate gracefully back to the ROOT prompt (at
>>>> the moment, depending on the stage within the loop (deep calls in
>>>> other
>>>> third-party libraries) I get the prompt, unhandled exceptions or
>>>> crash).
>>>> Schematically what we want to achieve is
>>>> shell prompt> root
>>>> [0] gSystem->Load("mylib.so")
>>>> [1] myProcess->Run(<100000 times for ~3 hours>)
>>>> .....
>>>> <at some point pressing ctrl-C and returning gracefully to>
>>>> [2]
>>>> Is there any tutorial on this? I see the classes TSignalHandler but a
>>>> piece of working code would help. Quickly greping in
>>>> $ROOTSYS/tutorials
>>>> did not return something. I would like if possible to avoid using
>>>> signal/slots ie the signal handler should preferably call directly a
>>>> function and not raise a ROOT/Qt type signal (but this scenario is
>>>> acceptable too).
>>>> Thanks,
>>>> filimon
>>
>

Received on Wed Jan 26 2011 - 17:37:03 CET

This archive was generated by hypermail 2.2.0 : Wed Jan 26 2011 - 23:50:01 CET