Rudiments
process.h
1 // Copyright (c) 2004 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 #ifdef RUDIMENTS_NAMESPACE
10 namespace rudiments {
11 #endif
12 
13 // wrap:
14 // unistd.h - nice()
15 // getgroups()
16 // vfork()
17 // profil()
18 // acct()
19 // getdtablesize()
20 // brk()/sbrk()
21 // syscall()
22 // sched.h - functions for manipulating the scheduler
23 // sched_setparam(),sched_getparam()
24 // sched_setscheduler(),sched_getscheduler()
25 // sched_yield(),
26 // sched_get_priority_max(),sched_get_priority_min()
27 // sched_rr_get_interval()
28 // sched_setaffinity(),sched_getaffinity()
29 // sys/acct.h - acct() - process accounting on/off
30 // sys/ptrace.h - ptrace()
31 // sys/resource.h - get/set process priority/resource usage
32 // getrlimit(),setrlimit()
33 // getrusage()
34 // getpriority(),setpriority()
35 // sys/times.h - times() - function for getting process times
36 // not in many systems -
37 // unistd.h - group_member()
38 // getresuid(),getresgid()
39 // setresuid(),setresgid()
40 // sys/gmon.h and sys/gmon_out.h - monstartup()
41 // linux only -
42 // execinfo.h - backtrace(),backtrace_symbols(),
43 // backtrace_symbols_fd()
44 // sys/prctl.h - prctl()
45 // not in bsd -
46 // ucontext.h - user-level context switching
47 // getcontext(),setcontext(),swapcontext(),makecontext()
48 
51 class RUDIMENTS_DLLSPEC process {
52  public:
53 
55  static pid_t getProcessId();
56 
59  static pid_t getParentProcessId();
60 
63  static pid_t getProcessGroupId();
64 
67  static pid_t getProcessGroupId(pid_t pid);
68 
71  static bool setProcessGroupId();
72 
74  static bool setProcessGroupId(pid_t pgid);
75 
77  static bool setProcessGroupId(pid_t pid, pid_t pgid);
78 
80  static pid_t getSessionId();
81 
83  static pid_t getSessionId(pid_t pid);
84 
86  static uid_t getRealUserId();
87 
89  static uid_t getEffectiveUserId();
90 
96  static bool setUserId(uid_t uid);
97 
102  static bool setEffectiveUserId(uid_t uid);
103 
111  static bool setRealAndEffectiveUserId(uid_t uid,
112  uid_t euid);
113 
115  static gid_t getRealGroupId();
116 
118  static gid_t getEffectiveGroupId();
119 
125  static bool setGroupId(gid_t gid);
126 
131  static bool setEffectiveGroupId(gid_t gid);
132 
140  static bool setRealAndEffectiveGroupId(gid_t gid,
141  gid_t egid);
142 
145  static mode_t setFileCreationMask(mode_t mask);
146 
154  static pid_t fork();
155 
161  static bool detach();
162 
165  static void exit(int32_t status);
166 };
167 
168 #ifdef RUDIMENTS_NAMESPACE
169 }
170 #endif
171 
172 #endif