00001 #include <grass/config.h> 00002 00003 #include <unistd.h> 00004 #include <grass/gis.h> 00005 00006 /************************************************************* 00007 * G_fork() 00008 * 00009 * Issue a system fork() call and protect the child from all 00010 * signals (which it does by changing the process group for the child) 00011 * 00012 * returns: 00013 * -1 fork failed. 00014 * 0 child 00015 * >0 parent 00016 ************************************************************/ 00017 00018 int G_fork(void) 00019 { 00020 #ifdef __MINGW32__ 00021 return -1; 00022 #else /* __MINGW32__ */ 00023 int pid; 00024 00025 pid = fork(); 00026 00027 /* 00028 * change the process group for the child (pid == 0) 00029 * note: we use the BSD calling sequence, since 00030 * it will work ok for ATT call which has no arguments 00031 */ 00032 if (pid == 0) 00033 #ifdef SETPGRP_VOID 00034 setpgrp(); 00035 #else 00036 setpgrp(0, getpid()); 00037 #endif 00038 00039 return pid; 00040 00041 #endif /* __MINGW32__ */ 00042 00043 }