Open Lighting Architecture
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Files | Functions
Initialization

Detailed Description

Functions called during program startup.

Programs using the OLA libraries should call either ServerInit() or AppInit(). There are also extra functions to help with installing signal handlers and daemonizing a process.

Example
// For client applications
AppInit(argc, argv);
// For server applications
ServerInit(argc, argv, &export_map);

Files

file  Init.cpp
file  Init.h
 Functions called during program startup.

Functions

bool ola::ServerInit (int argc, char *argv[], ExportMap *export_map)
 Used to initialize a server. Installs the SEGV handler, initializes the random number generator and populates the export map.
bool ola::AppInit (int argc, char *argv[])
 Used to initialize a application. Installs the SEGV handler and initializes the random number generator.
bool ola::InstallSignal (int signal, void(*fp)(int signo))
 Install a signal handler.
bool ola::InstallSEGVHandler ()
 Install signal handlers to deal with SIGBUS & SIGSEGV.
void ola::InitExportMap (int argc, char *argv[], ExportMap *export_map)
 Populate the ExportMap with a couple of basic variables.
void ola::Daemonise ()
 Run as a daemon.

Function Documentation

bool ola::AppInit ( int  argc,
char *  argv[] 
)

Used to initialize a application. Installs the SEGV handler and initializes the random number generator.

Parameters
argcargument count
argvpointer to the argument strings
Returns
true on success and false otherwise
Note
If you are a server then call ServerInit() instead.
void ola::Daemonise ( )

Run as a daemon.

Daemonize logs messages if it fails, so it's best to initialize the logging system (ola::InitLogging) before calling. However Daemonize() closes all open file descriptors so stdout/stderr will point to /dev/null in the daemon process. Therefore daemons should always use syslog logging.

If we can't daemonize the process is terminated.

See logging.

See Also
Logging
void ola::InitExportMap ( int  argc,
char *  argv[],
ExportMap *  export_map 
)

Populate the ExportMap with a couple of basic variables.

Parameters
argcargument count
argvpointer to the arugment strings
export_mapExportMap to populate

This is called by ServerInit(). It sets the following variables:

  • binary: name of the binary.
  • cmd-line: command line used to start the binary
  • fd-limit: the max number of file descriptors
bool ola::InstallSEGVHandler ( )

Install signal handlers to deal with SIGBUS & SIGSEGV.

Returns
true on success and false otherwise

On receiving a SIGBUS or SIGSEGV a stack trace will be printed.

bool ola::InstallSignal ( int  signal,
void(*)(int signo)  fp 
)

Install a signal handler.

Parameters
signalthe signal number to catch
fpis a function pointer to the handler
Returns
true on success and false otherwise
bool ola::ServerInit ( int  argc,
char *  argv[],
ExportMap *  export_map 
)

Used to initialize a server. Installs the SEGV handler, initializes the random number generator and populates the export map.

Parameters
argcargument count
argvpointer to argument strings
export_mapan optional pointer to an ExportMap
Returns
true on success and false otherwise
Note
If you are a client/application then call AppInit() instead.