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