process.h
// Copyright (c) 1999-2013 David Muse
// See the COPYING file for more information.
#ifndef RUDIMENTS_PROCESS_H
#define RUDIMENTS_PROCESS_H
#include <rudiments/private/processincludes.h>
enum childstatechange {
EXIT_CHILDSTATECHANGE=0,
TERMINATED_CHILDSTATECHANGE,
STOPPED_CHILDSTATECHANGE,
CONTINUED_CHILDSTATECHANGE
};
class RUDIMENTS_DLLSPEC process {
public:
static pid_t getProcessId();
static pid_t getParentProcessId();
static pid_t getProcessGroupId();
static pid_t getProcessGroupId(pid_t pid);
static bool setProcessGroupId();
static bool setProcessGroupId(pid_t pgid);
static bool setProcessGroupId(pid_t pid, pid_t pgid);
static pid_t getSessionId();
static pid_t getSessionId(pid_t pid);
static pid_t newSession();
static uid_t getRealUserId();
static uid_t getEffectiveUserId();
static bool setUserId(uid_t uid);
static bool setUser(const char *username);
static bool setEffectiveUserId(uid_t uid);
static bool setRealAndEffectiveUserId(uid_t uid,
uid_t euid);
static gid_t getRealGroupId();
static gid_t getEffectiveGroupId();
static bool setGroupId(gid_t gid);
static bool setGroup(const char *groupname);
static bool setEffectiveGroupId(gid_t gid);
static bool setRealAndEffectiveGroupId(gid_t gid,
gid_t egid);
static mode_t setFileCreationMask(mode_t mask);
static pid_t fork();
static bool exec(const char *command,
const char * const *args);
static pid_t spawn(const char *command,
const char * const *args);
static bool detach();
static void exit(int32_t status);
static void exitImmediately(int32_t status);
static void exitOnCrashOrShutDown();
static int64_t checkForPidFile(const char *filename);
static bool createPidFile(const char *filename,
mode_t permissions);
static void exitOnShutDown();
static void handleShutDown(
void (*shutdownfunction)(int32_t));
static void exitOnCrash();
static void handleCrash(void (*crashfunction)(int32_t));
static void waitForChildren();
static void dontWaitForChildren();
static pid_t getChildStateChange(pid_t pid,
bool wait,
bool ignorestop,
bool ignorecontinue,
childstatechange *newstate,
int32_t *exitstatus,
int32_t *signum,
bool *coredump);
#include <rudiments/private/process.h>
};
#endif