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

Rudiments

- Main Page
- Classes

process.h
1 // Copyright (c) 1999-2013 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(stringbuffer *buffer,
366 uint32_t maxframes);
367
374 static void backtrace(stringbuffer *buffer);
375
383 static void backtrace(filedescriptor *fd,
384 uint32_t maxframes);
385
393 static void backtrace(filedescriptor *fd);
394
401 static void backtrace(const char *filename);
402
412 static void backtrace(const char *filename,
413 mode_t perms,
414 uint32_t maxframes);
415
416 #include <rudiments/private/process.h>
417 };
418
419 #endif
stringbuffer
Definition: stringbuffer.h:22
permissions
Definition: permissions.h:28
process
Definition: process.h:19
filedescriptor
Definition: filedescriptor.h:14