blob: f3a21928dd0278596dc931e5cd69f8727cb82758 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#define NOPLAN9DEFINES
#include <lib9.h>
int
p9rfork(int flags)
{
int pid;
if((flags&(RFPROC|RFFDG|RFMEM)) == (RFPROC|RFFDG)){
/* check other flags before we commit */
flags &= ~(RFPROC|RFFDG);
if(flags & ~(RFNOTEG|RFNAMEG)){
werrstr("unknown flags %08ux in rfork", flags);
return -1;
}
pid = fork();
if(pid != 0)
return pid;
}
if(flags&RFPROC){
werrstr("cannot use rfork for shared memory -- use ffork");
return -1;
}
if(flags&RFNAMEG){
/* XXX set $NAMESPACE to a new directory */
flags &= ~RFNAMEG;
}
if(flags&RFNOTEG){
setpgid(0, getpid());
flags &= ~RFNOTEG;
}
if(flags){
werrstr("unknown flags %08ux in rfork", flags);
return -1;
}
return 0;
}
|