Skip to main content

Product: OpenFusion TAO
Version: ALL

Description:

Does TAO have a Termination Handler class?

 

Resolution:

Use the Shutdown_Utilities.h provided in the includes/orbsvcs directory, to create a shutdown_event_handler object. The code would need to be structured as follows:

#include "orbsvcs/Shutdown_Utilities.h"
//in addition to including this header you should also link libTAO_Svc_Utils.so

class My_Shutdown_Functor : public Shutdown_Functor {

public:

  My_Shutdown_Functor () {};

  void operator() (int which_signal);

  // ... whatever else you need ...
};

void
My_Shutdown_Functor::operator() (int which_signal) {
  // Perform your desired shutdown actions here
  // should typically include calling ::shutdown on the ORB etc..
}

Then instantiate this handler somewhere where it can remain in scope, e.g. the ::main method.

Use the following statement to instantiate the handler.

My_Shutdown_Functor my_functor;
Service_Shutdown shutdown_event_handler (my_functor);

For these handlers both SIGTERM and SIGINT would be caught and handled. Typically Ctrl-c sends INT, kill (by default) sends TERM.


#KnowledgeDocs
#OpenFusion