blob: 270c3cddf04043ca3151ea2bccf28094132b0cca (
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
|
#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)){
werrstr("unknown flags %08ux in rfork", flags);
return -1;
}
pid = fork();
if(pid != 0)
return pid;
}
if(flags&RFPROC){
werrstr("cannot use rfork to fork -- use ffork");
return -1;
}
if(flags&RFNOTEG){
setpgid(0, getpid());
flags &= ~RFNOTEG;
}
if(flags){
werrstr("unknown flags %08ux in rfork", flags);
return -1;
}
return 0;
}
|