/* * $HEADER$ */ #include "ompi_config.h" #include #include #include #include #include #include "include/constants.h" #include "util/daemon_init.h" int daemon_init(char *working_dir) { pid_t pid; if ((pid = fork()) < 0) { return OMPI_ERROR; } else if (pid != 0) { exit(0); /* parent goes bye-bye */ } /* child continues */ setsid(); /* become session leader */ if (NULL != working_dir) { chdir(working_dir); /* change working directory */ } umask(0); /* clear file mode creation mask */ return OMPI_SUCCESS; }