LRAUV  revA
SimDaemon Class Reference

Combines a EnvSimulator with a SocketServer to provide

either remote, or out-of-process simulation. More...

#include <SimDaemon.h>

Collaboration diagram for SimDaemon:

Public Member Functions

 SimDaemon (bool debug)
 
virtual ~SimDaemon ()
 
void run () throw ( SocketException& )
 

Static Public Member Functions

static void Daemonize (bool hideOutputs)
 Code borrowed from http://www-theorie.physik.unizh.ch/~dpotter/howto/daemonize. More...
 

Static Public Attributes

static const int SOCKET_SERVER_PORT = SIMPORT
 

Private Member Functions

 SimDaemon (const SimDaemon &old)
 

Static Private Member Functions

static void * ServiceClient (void *clientSocketPtr)
 

Private Attributes

SocketServersocketServer_
 

Static Private Attributes

static bool Debug_
 
static bool Shutdown_
 
static Mutex ShutdownMutex_
 
static FastMap< uint64_t, EnvSimulator * > SimulatorMap_
 

Detailed Description

Combines a EnvSimulator with a SocketServer to provide

either remote, or out-of-process simulation.

Should be run as a daemon.

Constructor & Destructor Documentation

SimDaemon::SimDaemon ( bool  debug)

References Debug_.

SimDaemon::~SimDaemon ( )
virtual
SimDaemon::SimDaemon ( const SimDaemon old)
private

Member Function Documentation

void SimDaemon::Daemonize ( bool  hideOutputs)
static

Code borrowed from http://www-theorie.physik.unizh.ch/~dpotter/howto/daemonize.

To properly daemonize, the following steps must be followed.

  • The fork() call is used to create a separate process.
  • The setsid() call is used to detach the process from the parent (normally a shell).
  • The file mask should be reset.
  • The current directory should be changed to something benign.
    • We do not do this since we want to open a file at a relative position
  • The standard files (stdin,stdout and stderr) need to be reopened.

Failure to do any of these steps will lead to a daemon process that can misbehave. The typical symptoms are as follows.

  • Starting the daemon and then logging out will cause the terminal to hang. This is particularly nasty with ssh.
  • The directory from which the daemon was launched remains locked.
  • Spurious output appears in the shell from which the daemon was started.

References EXIT_FAILURE, and EXIT_SUCCESS.

Referenced by main().

void SimDaemon::run ( void  )
throw (SocketException &
)

Member Data Documentation

bool SimDaemon::Debug_
staticprivate

Referenced by ServiceClient(), and SimDaemon().

bool SimDaemon::Shutdown_
staticprivate

Referenced by run(), and ServiceClient().

Mutex SimDaemon::ShutdownMutex_
staticprivate

Referenced by ~SimDaemon().

FastMap< uint64_t, EnvSimulator * > SimDaemon::SimulatorMap_
staticprivate

Referenced by ServiceClient(), and ~SimDaemon().

const int SimDaemon::SOCKET_SERVER_PORT = SIMPORT
static

Referenced by run().

SocketServer* SimDaemon::socketServer_
private

The documentation for this class was generated from the following files: