44#ifndef COMMONCPP_PROCESS_H_
45#define COMMONCPP_PROCESS_H_
47#ifndef COMMONCPP_CONFIG_H_
48#include <commoncpp/config.h>
51#ifndef COMMONCPP_THREAD_H_
76 typedef void (*Trap)(int);
92 static void attach(
const char *devname);
144 static int spawn(
const char *exec,
const char **argv,
bool wait =
true);
162 static bool cancel(
int pid,
int sig = 0);
170 static const char *
getEnv(
const char *name);
179 static void setEnv(
const char *name,
const char *value,
bool overwrite);
207 static bool setUser(
const char *
id,
bool grp =
true);
A class for containing portable process related functions that help create portable code.
static size_t getPageSize(void)
Return the effective operating system page size.
static const char * getConfigDir(void)
Get etc prefix path.
static bool setUser(const char *id, bool grp=true)
Set user id by name.
static void setRealtime(int pri=0)
Portable shortcut for setting realtime...
static const char * getUser(void)
Get user name.
void unlock(void)
Unlock process pages.
static const char * getEnv(const char *name)
Get system environment.
bool lock(bool future=true)
Lock a process in memory.
static void detach(void)
Detach current process into a daemon, posix only.
static const char * getHomeDir(void)
Get home directory.
static void setScheduler(const char *policy)
Used to set process scheduling policy.
static bool isRealtime(void)
Return true if realtime scheduling.
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 setPriority(int pri)
Used to set process priority and optionally enable realtime.
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 int join(int pid)
Get the exit status of another process, waiting for it to exit.
static Trap setPosixSignal(int signo, Trap handler)
Set a posix compliant signal handler.
static Trap setInterruptSignal(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 bool isScheduler(void)
Return true if scheduler settable.
This class is used to create a "named" lock entity that can be used to control access to a resource b...
bool lock(const char *name)
Lock a system-wide name for this process.
bool isLocked(void)
Flag if the current process has aqcuired a lock.
Lockfile(const char *name)
Create a lock under a known name.
Lockfile()
Create a new lock object that can be used to make locks.
~Lockfile()
Destroy the current lock and release it.
void unlock(void)
Release an acquired lock.
Common C++ thread class and sychronization objects.