ost::Process - A class for containing portable process related functions that help create portable code.
Contents
Detailed Description
A class for containing portable process related functions that help create portable code.
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.
Peocess wrapper class.
Author
David Sugar dyfet@ostel.comMember Function Documentation
staticvoidost::Process::attach(constchar*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.
Parametersdevname path to attach to.
staticboolost::Process::cancel(intpid,intsig=0)[static]
Cancel a running child process.
Returns
0 on success.
Parameterspid process id.
sig cancel signal to apply.
staticvoidost::Process::detach(void)[static]
Detach current process into a daemon, posix only. Perhaps a similar method can be used for creating win32
'services'?
staticconstchar*ost::Process::getConfigDir(void)[static]
Get etc prefix path.
Returns
etc prefix.
staticconstchar*ost::Process::getEnv(constchar*name)[static]
Get system environment.
Returns
system environ symbol.
Parametersname of symbol.
staticconstchar*ost::Process::getHomeDir(void)[static]
Get home directory.
Returns
user home directory.
staticsize_tost::Process::getPageSize(void)[static]
Return the effective operating system page size.
Returns
system page size.
staticconstchar*ost::Process::getUser(void)[static]
Get user name.
Returns
user login id.
staticboolost::Process::isRealtime(void)[inline],[static]
Return true if realtime scheduling.
staticboolost::Process::isScheduler(void)[static]
Return true if scheduler settable.
staticintost::Process::join(intpid)[static]
Get the exit status of another process, waiting for it to exit.
Returns
exit code from process.
Parameterspid process id.
boolost::Process::lock(boolfuture=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.
Parametersfuture pages as well...
staticvoidost::Process::setEnv(constchar*name,constchar*value,booloverwrite)[static]
Set system environment in a standard manner.
Parametersname of environment symbol to set.
value of environment symbol.
overwrite true if replace existing symbol.
staticboolost::Process::setGroup(constchar*id)[static]
Set the effective group id by name.
Returns
true if successful.
staticTrapost::Process::setInterruptSignal(intsigno,Traphandler)[static]
Set system call interuptable signal handler. #return previous handler.
Parameterssigno signal no.
handler trap handler.
staticTrapost::Process::setPosixSignal(intsigno,Traphandler)[static]
Set a posix compliant signal handler.
Returns
previous handler.
Parameterssigno signal no.
handler trap handler.
staticvoidost::Process::setPriority(intpri)[static]
Used to set process priority and optionally enable realtime.
staticvoidost::Process::setRealtime(intpri=0)[static]
Portable shortcut for setting realtime...
staticvoidost::Process::setScheduler(constchar*policy)[static]
Used to set process scheduling policy.
staticboolost::Process::setUser(constchar*id,boolgrp=true)[static]
Set user id by name.
Returns
true if successful.
staticintost::Process::spawn(constchar*exec,constchar**argv,boolwait=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.
Parametersexec name of executable.
argv list of command arguments.
wait for process to exit before return.
voidost::Process::unlock(void)
Unlock process pages.
Member Typedef Documentation
typedefRETSIGTYPE(*ost::Process::Trap)(int)
Name
ost::Process - A class for containing portable process related functions that help create portable code.
Synopsis
#include <process.h>
PublicTypes
typedef RETSIGTYPE(* Trap) (int)
PublicMemberFunctions
bool lock (bool future=true)
Lock a process in memory.
void unlock (void)
Unlock process pages.
StaticPublicMemberFunctions
static void detach (void)
Detach current process into a daemon, posix only.
static void attach (const char *devname)
Attach the current process to another device or i/o session.
static TrapsetPosixSignal (int signo, Trap handler)
Set a posix compliant signal handler.
static TrapsetInterruptSignal (int signo, Trap handler)
Set system call interuptable signal handler.
static int spawn (const char *exec, const char **argv, bool wait=true)
Spawn a process and wait for it's exit code.
static int join (int pid)
Get the exit status of another process, waiting for it to exit.
static bool cancel (int pid, int sig=0)
Cancel a running child process.
static const char * getEnv (const char *name)
Get system environment.
static void setEnv (const char *name, const char *value, bool overwrite)
Set system environment in a standard manner.
static const char * getConfigDir (void)
Get etc prefix path.
static const char * getHomeDir (void)
Get home directory.
static const char * getUser (void)
Get user name.
static bool setUser (const char *id, bool grp=true)
Set user id by name.
static bool setGroup (const char *id)
Set the effective group id by name.
static size_t getPageSize (void)
Return the effective operating system page size.
static void setPriority (int pri)
Used to set process priority and optionally enable realtime.
static void setScheduler (const char *policy)
Used to set process scheduling policy.
static void setRealtime (int pri=0)
Portable shortcut for setting realtime...
static bool isScheduler (void)
Return true if scheduler settable.
static bool isRealtime (void)
Return true if realtime scheduling.
