A class for containing portable process related functions that help create portable code. More...
#include <process.h>
Public Types | |
| typedef void(* | Trap )(int) |
Public Member Functions | |
| bool | lock (bool future=true) |
| Lock a process in memory. | |
| void | unlock (void) |
| Unlock process pages. | |
Static Public Member Functions | |
| static void | attach (const char *devname) |
| Attach the current process to another device or i/o session. | |
| static bool | cancel (int pid, int sig=0) |
| Cancel a running child process. | |
| static void | detach (void) |
| Detach current process into a daemon, posix only. | |
| static const char * | getConfigDir (void) |
| Get etc prefix path. | |
| static const char * | getEnv (const char *name) |
| Get system environment. | |
| static const char * | getHomeDir (void) |
| Get home directory. | |
| static size_t | getPageSize (void) |
| Return the effective operating system page size. | |
| static const char * | getUser (void) |
| Get user name. | |
| static bool | isRealtime (void) |
| Return true if realtime scheduling. | |
| static bool | isScheduler (void) |
| Return true if scheduler settable. | |
| static int | join (int pid) |
| Get the exit status of another process, waiting for it to exit. | |
| static void | setEnv (const char *name, const char *value, bool overwrite) |
| Set system environment in a standard manner. | |
| static bool | setGroup (const char *id) |
| Set the effective group id by name. | |
| static Trap | setInterruptSignal (int signo, Trap handler) |
| Set system call interuptable signal handler. | |
| static Trap | setPosixSignal (int signo, Trap handler) |
| Set a posix compliant signal handler. | |
| static void | setPriority (int pri) |
| Used to set process priority and optionally enable realtime. | |
| static void | setRealtime (int pri=0) |
| Portable shortcut for setting realtime. | |
| static void | setScheduler (const char *policy) |
| Used to set process scheduling policy. | |
| static bool | setUser (const char *id, bool grp=true) |
| Set user id by name. | |
| static int | spawn (const char *exec, const char **argv, bool wait=true) |
| Spawn a process and wait for it's exit code. | |
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.
Definition at line 66 of file process.h.
| static 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.
| devname | path to attach to. |
| static bool ost::Process::cancel | ( | int | pid, | |
| int | sig = 0 | |||
| ) | [static] |
Cancel a running child process.
| pid | process id. | |
| sig | cancel signal to apply. |
| static 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"?
| static const char* ost::Process::getConfigDir | ( | void | ) | [static] |
Get etc prefix path.
| static const char* ost::Process::getEnv | ( | const char * | name | ) | [static] |
Get system environment.
| name | of symbol. |
| static const char* ost::Process::getHomeDir | ( | void | ) | [static] |
Get home directory.
| static size_t ost::Process::getPageSize | ( | void | ) | [static] |
Return the effective operating system page size.
| static const char* ost::Process::getUser | ( | void | ) | [static] |
Get user name.
| static int ost::Process::join | ( | int | pid | ) | [static] |
Get the exit status of another process, waiting for it to exit.
| 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.
| future | pages as well... |
| static void ost::Process::setEnv | ( | const char * | name, | |
| const char * | value, | |||
| bool | overwrite | |||
| ) | [static] |
Set system environment in a standard manner.
| name | of environment symbol to set. | |
| value | of environment symbol. | |
| overwrite | true if replace existing symbol. |
| static bool ost::Process::setGroup | ( | const char * | id | ) | [static] |
Set the effective group id by name.
| static Trap ost::Process::setInterruptSignal | ( | int | signo, | |
| Trap | handler | |||
| ) | [static] |
Set system call interuptable signal handler.
return previous handler.
| signo | signal no. | |
| handler | trap handler. |
| static Trap ost::Process::setPosixSignal | ( | int | signo, | |
| Trap | handler | |||
| ) | [static] |
Set a posix compliant signal handler.
| signo | signal no. | |
| handler | trap handler. |
| static void ost::Process::setRealtime | ( | int | pri = 0 |
) | [static] |
Portable shortcut for setting realtime.
..
| static bool ost::Process::setUser | ( | const char * | id, | |
| bool | grp = true | |||
| ) | [static] |
Set user id by name.
| static 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.
| exec | name of executable. | |
| argv | list of command arguments. | |
| wait | for process to exit before return. |
1.6.1