Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Examples  

ost::Process Class Reference

A class for containing portable process related functions that help create portable code. Peocess wrapper class. More...

#include <process.h>

List of all members.

Public Types

typedef RETSIGTYPE (* Trap )(int)

Public Methods

bool lock (bool future=true)
 Lock a process in memory. More...

void unlock (void)
 Unlock process pages. More...


Static Public Methods

void detach (void)
 Detach current process into a daemon, posix only. More...

void attach (const char *devname)
 Attach the current process to another device or i/o session. More...

Trap setPosixSignal (int signo, Trap handler)
 Set a posix compliant signal handler. More...

Trap setInterruptSignal (int signo, Trap handler)
 Set system call interuptable signal handler. More...

int spawn (const char *exec, const char **argv, bool wait=true)
 Spawn a process and wait for it's exit code. More...

int join (int pid)
 Get the exit status of another process, waiting for it to exit. More...

bool cancel (int pid, int sig=0)
 Cancel a running child process. More...

const char* getEnv (const char *name)
 Get system environment. More...

void setEnv (const char *name, const char *value, bool overwrite)
 Set system environment in a standard manner. More...

const char* getConfigDir (void)
 Get etc prefix path. More...

const char* getHomeDir (void)
 Get home directory. More...

const char* getUser (void)
 Get user name. More...

bool setUser (const char *id, bool grp=true)
 Set user id by name. More...

bool setGroup (const char *id)
 Set the effective group id by name. More...

size_t getPageSize (void)
 Return the effective operating system page size. More...

void setPriority (int pri)
 Used to set process priority and optionally enable realtime. More...

void setScheduler (const char *policy)
 Used to set process scheduling policy. More...

void setRealtime (int pri=0)
 Portable shortcut for setting realtime... More...

bool isScheduler (void)
 Return true if scheduler settable. More...

bool isRealtime (void)
 Return true if realtime scheduling. More...


Detailed Description

A class for containing portable process related functions that help create portable code. Peocess wrapper class.

These are typically referenced thru Process::xxx static member functions. Many of these members are used both for win32 and posix systems although some may be platform specific.

Author:
David Sugar <dyfet@ostel.com>


Member Typedef Documentation

typedef RETSIGTYPE(* ost::Process::Trap)(int)
 


Member Function Documentation

void ost::Process::attach ( const char * devname ) [static]
 

Attach the current process to another device or i/o session.

It is deamonified and dissasociated with the prior parent process and controlling terminal.

Parameters:
devname   path to attach to.

bool ost::Process::cancel ( int pid,
int sig = 0 ) [static]
 

Cancel a running child process.

Returns:
0 on success.
Parameters:
pid   process id.
sig   cancel signal to apply.

void ost::Process::detach ( void ) [static]
 

Detach current process into a daemon, posix only.

Perhaps a similar method can be used for creating win32 "services"?

const char * ost::Process::getConfigDir ( void ) [static]
 

Get etc prefix path.

Returns:
etc prefix.

const char * ost::Process::getEnv ( const char * name ) [static]
 

Get system environment.

Returns:
system environ symbol.
Parameters:
name   of symbol.

const char * ost::Process::getHomeDir ( void ) [static]
 

Get home directory.

Returns:
user home directory.

size_t ost::Process::getPageSize ( void ) [static]
 

Return the effective operating system page size.

Returns:
system page size.

const char * ost::Process::getUser ( void ) [static]
 

Get user name.

Returns:
user login id.

bool ost::Process::isRealtime ( void ) [inline, static]
 

Return true if realtime scheduling.

bool ost::Process::isScheduler ( void ) [static]
 

Return true if scheduler settable.

int ost::Process::join ( int pid ) [static]
 

Get the exit status of another process, waiting for it to exit.

Returns:
exit code from process.
Parameters:
pid   process id.

bool ost::Process::lock ( bool future = true )
 

Lock a process in memory.

Ideally you should be deep enough where additional memallocs for functions will not kill you, or use false for future.

Returns:
true if successful.
Parameters:
future   pages as well...

void ost::Process::setEnv ( const char * name,
const char * value,
bool overwrite ) [static]
 

Set system environment in a standard manner.

Parameters:
name   of environment symbol to set.
value   of environment symbol.
overwrite   true if replace existing symbol.

bool ost::Process::setGroup ( const char * id ) [static]
 

Set the effective group id by name.

Returns:
true if successful.

Trap ost::Process::setInterruptSignal ( int signo,
Trap handler ) [static]
 

Set system call interuptable signal handler.

return previous handler.

Parameters:
signo   signal no.
handler   trap handler.

Trap ost::Process::setPosixSignal ( int signo,
Trap handler ) [static]
 

Set a posix compliant signal handler.

Returns:
previous handler.
Parameters:
signo   signal no.
handler   trap handler.

void ost::Process::setPriority ( int pri ) [static]
 

Used to set process priority and optionally enable realtime.

void ost::Process::setRealtime ( int pri = 0 ) [static]
 

Portable shortcut for setting realtime...

void ost::Process::setScheduler ( const char * policy ) [static]
 

Used to set process scheduling policy.

bool ost::Process::setUser ( const char * id,
bool grp = true ) [static]
 

Set user id by name.

Returns:
true if successful.

int ost::Process::spawn ( const char * exec,
const char ** argv,
bool wait = true ) [static]
 

Spawn a process and wait for it's exit code.

In win32 this is done with the spawn system call. In posix, this is done with a fork, an execvp, and a waitpid.

Warning:
The implementation differences between posix and win32 systems may cause side effects. For instance, if you use atexit() and this spawn method, on posix systems the function set up with atexit() will be called when the parent process of the fork exits, which will not happen on Win32 systems.

Returns:
error code from process.
Parameters:
exec   name of executable.
argv   list of command arguments.
wait   for process to exit before return.

void ost::Process::unlock ( void )
 

Unlock process pages.


The documentation for this class was generated from the following file:
Generated at Fri May 30 14:51:03 2008 for GNU CommonC++ by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001