plan9port/src/lib9/rfork.c

35 lines
593 B
C
Raw Normal View History

2003-11-23 18:12:54 +00:00
#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;
}
2003-11-23 18:12:54 +00:00
if(flags&RFPROC){
werrstr("cannot use rfork to fork -- use ffork");
return -1;
}
if(flags&RFNOTEG){
2003-11-23 19:49:17 +00:00
setpgid(0, getpid());
2003-11-23 18:12:54 +00:00
flags &= ~RFNOTEG;
}
if(flags){
werrstr("unknown flags %08ux in rfork", flags);
return -1;
}
return 0;
}