Rudiments: /home/dmuse/temp/rudiments/include/rudiments/process.h Source File

Rudiments

process.h
1 // Copyright (c) 1999-2018 David Muse
2 // See the COPYING file for more information.
3
4 #ifndef RUDIMENTS_PROCESS_H
5 #define RUDIMENTS_PROCESS_H
6
7 #include <rudiments/private/processincludes.h>
8
9 enum childstatechange {
10 EXIT_CHILDSTATECHANGE=0,
11 TERMINATED_CHILDSTATECHANGE,
12 STOPPED_CHILDSTATECHANGE,
13 CONTINUED_CHILDSTATECHANGE
14 };
15
19 class RUDIMENTS_DLLSPEC process {
20 public:
21
23 static pid_t getProcessId();
24
27 static pid_t getParentProcessId();
28
31 static pid_t getProcessGroupId();
32
35 static pid_t getProcessGroupId(pid_t pid);
36
39 static bool setProcessGroupId();
40
42 static bool setProcessGroupId(pid_t pgid);
43
45 static bool setProcessGroupId(pid_t pid, pid_t pgid);
46
48 static pid_t getSessionId();
49
51 static pid_t getSessionId(pid_t pid);
52
57 static pid_t newSession();
58
60 static uid_t getUserId();
61
63 static uid_t getEffectiveUserId();
64
70 static bool setUserId(uid_t uid);
71
77 static bool setUser(const char *username);
78
83 static bool setEffectiveUserId(uid_t uid);
84
90 static bool setEffectiveUser(const char *username);
91
99 static bool setRealAndEffectiveUserId(uid_t uid,
100 uid_t euid);
101
103 static gid_t getGroupId();
104
106 static gid_t getEffectiveGroupId();
107
113 static bool setGroupId(gid_t gid);
114
120 static bool setGroup(const char *groupname);
121
126 static bool setEffectiveGroupId(gid_t gid);
127
133 static bool setEffectiveGroup(const char *groupname);
134
142 static bool setRealAndEffectiveGroupId(gid_t gid,
143 gid_t egid);
144
147 static mode_t setFileCreationMask(mode_t mask);
148
156 static pid_t fork();
157
160 static bool supportsFork();
161
170 static bool exec(const char *command,
171 const char * const *args);
172
183 static pid_t spawn(const char *command,
184 const char * const *args,
185 bool detached);
186
192 static bool detach();
193
196 static void exit(int32_t status);
197
201 static void exitImmediately(int32_t status);
202
205 static bool sendSignal(pid_t processid, int32_t signum);
206
209 static bool raiseSignal(int32_t signum);
210
214 static bool atExit(void (*function)(void));
215
218 static void exitOnCrashOrShutDown();
219
223 static int64_t checkForPidFile(const char *filename);
224
232 static bool createPidFile(const char *filename,
233 mode_t permissions);
234
240 static void exitOnShutDown();
241
245 static void handleShutDown(
246 void (*shutdownfunction)(int32_t));
247
254 static void exitOnCrash();
255
260 static void handleCrash(void (*crashfunction)(int32_t));
261
265 static void waitForChildren();
266
273 static void dontWaitForChildren();
274
278 static bool wait(pid_t pid);
279
284 static bool wait(pid_t pid, int32_t *exitstatus);
285
329 static pid_t getChildStateChange(pid_t pid,
330 bool wait,
331 bool ignorestop,
332 bool ignorecontinue,
333 childstatechange *newstate,
334 int32_t *exitstatus,
335 int32_t *signum,
336 bool *coredump);
337
340 static bool supportsGetChildStateChange();
341
347 static void retryFailedFork();
348
353 static void dontRetryFailedFork();
354
357 static bool getRetryFailedFork();
358
365 static void backtrace(output *out, uint32_t maxframes);
366
373 static void backtrace(output *out);
374
381 static void backtrace(const char *filename);
382
392 static void backtrace(const char *filename,
393 mode_t perms,
394 uint32_t maxframes);
395
396 #include <rudiments/private/process.h>
397 };
398
399 #endif
output
Definition: output.h:9
permissions
Definition: permissions.h:28
process
Definition: process.h:19
process::setEffectiveUser
static bool setEffectiveUser(const char *username)
process::backtrace
static void backtrace(output *out, uint32_t maxframes)
process::getProcessGroupId
static pid_t getProcessGroupId(pid_t pid)
process::exec
static bool exec(const char *command, const char *const *args)
process::setEffectiveUserId
static bool setEffectiveUserId(uid_t uid)
process::newSession
static pid_t newSession()
process::exitImmediately
static void exitImmediately(int32_t status)
process::getSessionId
static pid_t getSessionId()
process::waitForChildren
static void waitForChildren()
process::setUserId
static bool setUserId(uid_t uid)
process::retryFailedFork
static void retryFailedFork()
process::setRealAndEffectiveGroupId
static bool setRealAndEffectiveGroupId(gid_t gid, gid_t egid)
process::setEffectiveGroup
static bool setEffectiveGroup(const char *groupname)
process::setUser
static bool setUser(const char *username)
process::getGroupId
static gid_t getGroupId()
process::getEffectiveGroupId
static gid_t getEffectiveGroupId()
process::atExit
static bool atExit(void(*function)(void))
process::getSessionId
static pid_t getSessionId(pid_t pid)
process::fork
static pid_t fork()
process::exitOnCrash
static void exitOnCrash()
process::setGroupId
static bool setGroupId(gid_t gid)
process::setProcessGroupId
static bool setProcessGroupId(pid_t pid, pid_t pgid)
process::getChildStateChange
static pid_t getChildStateChange(pid_t pid, bool wait, bool ignorestop, bool ignorecontinue, childstatechange *newstate, int32_t *exitstatus, int32_t *signum, bool *coredump)
process::setEffectiveGroupId
static bool setEffectiveGroupId(gid_t gid)
process::supportsFork
static bool supportsFork()
process::wait
static bool wait(pid_t pid)
process::setGroup
static bool setGroup(const char *groupname)
process::handleShutDown
static void handleShutDown(void(*shutdownfunction)(int32_t))
process::exit
static void exit(int32_t status)
process::getParentProcessId
static pid_t getParentProcessId()
process::setProcessGroupId
static bool setProcessGroupId(pid_t pgid)
process::getUserId
static uid_t getUserId()
process::dontRetryFailedFork
static void dontRetryFailedFork()
process::spawn
static pid_t spawn(const char *command, const char *const *args, bool detached)
process::exitOnCrashOrShutDown
static void exitOnCrashOrShutDown()
process::getEffectiveUserId
static uid_t getEffectiveUserId()
process::backtrace
static void backtrace(const char *filename)
process::setProcessGroupId
static bool setProcessGroupId()
process::sendSignal
static bool sendSignal(pid_t processid, int32_t signum)
process::checkForPidFile
static int64_t checkForPidFile(const char *filename)
process::getRetryFailedFork
static bool getRetryFailedFork()
process::dontWaitForChildren
static void dontWaitForChildren()
process::setRealAndEffectiveUserId
static bool setRealAndEffectiveUserId(uid_t uid, uid_t euid)
process::detach
static bool detach()
process::raiseSignal
static bool raiseSignal(int32_t signum)
process::wait
static bool wait(pid_t pid, int32_t *exitstatus)
process::getProcessGroupId
static pid_t getProcessGroupId()
process::handleCrash
static void handleCrash(void(*crashfunction)(int32_t))
process::supportsGetChildStateChange
static bool supportsGetChildStateChange()
process::exitOnShutDown
static void exitOnShutDown()
process::createPidFile
static bool createPidFile(const char *filename, mode_t permissions)
process::backtrace
static void backtrace(const char *filename, mode_t perms, uint32_t maxframes)
process::getProcessId
static pid_t getProcessId()
process::backtrace
static void backtrace(output *out)
process::setFileCreationMask
static mode_t setFileCreationMask(mode_t mask)