Back to index

salome-kernel  6.5.0
Typedefs | Functions | Variables
SALOME_Container.cxx File Reference
#include <iostream>
#include <sstream>
#include <string>
#include <stdio.h>
#include <time.h>
#include <sys/time.h>
#include <dlfcn.h>
#include <unistd.h>
#include "SALOME_Container_i.hxx"
#include "utilities.h"
#include "Utils_ORB_INIT.hxx"
#include "Utils_SINGLETON.hxx"
#include "OpUtil.hxx"
#include "Container_init_python.hxx"
#include <stdexcept>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>

Go to the source code of this file.

Typedefs

typedef void(* sighandler_t )(int)

Functions

void HandleServerSideSignals (CORBA::ORB_ptr theORB)
void AttachDebugger ()
void Handler (int)
void terminateHandler ()
void unexpectedHandler ()
sighandler_t setsig (int sig, sighandler_t handler)
int main (int argc, char *argv[])

Variables

void(*)(int) setsig (int, void(*)(int))

Typedef Documentation

typedef void(* sighandler_t)(int)

Definition at line 80 of file SALOME_Container.cxx.


Function Documentation

void AttachDebugger ( )

Definition at line 93 of file SALOME_Container.cxx.

{
#ifndef WIN32
  if(getenv ("DEBUGGER"))
    {
      std::stringstream exec;
      exec << "$DEBUGGER SALOME_Container " << getpid() << "&";
      std::cerr << exec.str() << std::endl;
      system(exec.str().c_str());
      while(1);
    }
#endif
}

Here is the caller graph for this function:

void Handler ( int  theSigId)

Definition at line 107 of file SALOME_Container.cxx.

{
  std::cerr << "Signal= "<< theSigId  << std::endl;
  AttachDebugger();
  //to exit or not to exit
  _exit(1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void HandleServerSideSignals ( CORBA::ORB_ptr  theORB)

Definition at line 32 of file SALOME_Container_SignalsHandler.cxx.

{
 // CCRT porting
 //  CASCatch_SignalsHandler aSignalsHandler;
  try {
    theORB->run();
    // CCRT porting
    //  }catch(CORBA::SystemException&){
    //    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
    //    throw std::runtime_error(aFail->GetMessageString());
  }catch(CORBA::SystemException&){
    INFOS("Caught CORBA::SystemException.");
  }catch(PortableServer::POA::WrongPolicy&){
    INFOS("Caught CORBA::WrongPolicyException.");
  }catch(PortableServer::POA::ServantAlreadyActive&){
    INFOS("Caught CORBA::ServantAlreadyActiveException");
  }catch(CORBA::Exception&){
    INFOS("Caught CORBA::Exception.");
  }catch(std::exception& exc){
    INFOS("Caught std::exception - "<<exc.what()); 
  }catch(...){
    INFOS("Caught unknown exception.");
  }
}

Here is the caller graph for this function:

int main ( int  argc,
char *  argv[] 
)

Definition at line 127 of file SALOME_Container.cxx.

{
#ifdef _MPI_SEQ_CONTAINER_
  #ifdef HAVE_MPI2
  MPI_Init(&argc,&argv);
  #endif
#endif  

#ifndef WIN32
  if(getenv ("DEBUGGER"))
    {
      setsig(SIGSEGV,&Handler);
      setsig(SIGFPE,&Handler);
      std::set_terminate(&terminateHandler);
      std::set_unexpected(&unexpectedHandler);
    }
#endif

  // Initialise the ORB.
  //SRN: BugID: IPAL9541, it's necessary to set a size of one message to be at least 100Mb
  //CORBA::ORB_var orb = CORBA::ORB_init( argc , argv ) ;
  ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
  ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
  CORBA::ORB_ptr orb = init(argc , argv ) ;

  //  LocalTraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb);
  INFOS_COMPILATION;
  BEGIN_OF(argv[0]);

  ASSERT(argc > 1);
  SCRUTE(argv[1]);

  KERNEL_PYTHON::init_python(argc,argv);
    
  char *containerName = (char *)"";
  if(argc > 1)
    {
      containerName = argv[1] ;
    }

  try
    {  
      CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
      ASSERT(!CORBA::is_nil(obj));
      PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);

      PortableServer::POAManager_var pman = root_poa->the_POAManager();

      // add new container to the kill list
#ifndef WIN32
      std::stringstream aCommand ;
      aCommand << "addToKillList.py " << getpid() << " SALOME_Container" << std::ends ;
      system(aCommand.str().c_str());
#endif
      
      new Engines_Container_i(orb, root_poa, containerName , argc , argv );
      
      pman->activate();
      
#ifdef CHECKTIME
      Utils_Timer timer;
      timer.Start();
      timer.Stop();
      timer.ShowAbsolute();
#endif

      HandleServerSideSignals(orb);

//#define MEMORYLEAKS
#ifdef MEMORYLEAKS
        PyGILState_Ensure();
        //Destroy orb from python (for chasing memory leaks)
        PyRun_SimpleString("from omniORB import CORBA");
        PyRun_SimpleString("orb=CORBA.ORB_init([''], CORBA.ORB_ID)");
        PyRun_SimpleString("orb.destroy()");
        Py_Finalize();
#endif
    }
  catch(CORBA::SystemException&)
    {
      INFOS("Caught CORBA::SystemException.");
    }
  catch(PortableServer::POA::ServantAlreadyActive&)
    {
      INFOS("Caught CORBA::ServantAlreadyActiveException");
    }
  catch(CORBA::Exception&)
    {
      INFOS("Caught CORBA::Exception.");
    }
  catch(std::exception& exc)
    {
      INFOS("Caught std::exception - "<<exc.what()); 
    }
  catch(...)
    {
      INFOS("Caught unknown exception.");
    }

#ifdef _MPI_SEQ_CONTAINER_
  #ifdef HAVE_MPI2
  MPI_Finalize();
  #endif
#endif  

  return 0 ;
}

Here is the call graph for this function:

sighandler_t setsig ( int  sig,
sighandler_t  handler 
)

Definition at line 81 of file SALOME_Container.cxx.

{
  struct sigaction context, ocontext;
  context.sa_handler = handler;
  sigemptyset(&context.sa_mask);
  context.sa_flags = 0;
  if (sigaction(sig, &context, &ocontext) == -1)
    return SIG_ERR;
  return ocontext.sa_handler;
}
void terminateHandler ( void  )

Definition at line 115 of file SALOME_Container.cxx.

{
  std::cerr << "Terminate: not managed exception !"  << std::endl;
  AttachDebugger();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unexpectedHandler ( void  )

Definition at line 121 of file SALOME_Container.cxx.

{
  std::cerr << "Unexpected: unexpected exception !"  << std::endl;
  AttachDebugger();
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

void(* )(int) setsig(int, void(*)(int))

Definition at line 78 of file SALOME_Container.cxx.