diff options
author | root <root@ka-ata-killa.panaceas.james.internal> | 2022-04-09 11:57:42 +0100 |
---|---|---|
committer | root <root@ka-ata-killa.panaceas.james.internal> | 2022-04-09 11:57:42 +0100 |
commit | 338dcccc8d8532a446fa60dc65092b5510c06e3a (patch) | |
tree | 85c40cfec1a44b43a278d164f6a6c20576fd8aba /email.c | |
parent | c44cf3a3f0a73ad276c0316759fcb0d8a0d22032 (diff) | |
download | galaxy_tools-338dcccc8d8532a446fa60dc65092b5510c06e3a.tar.gz galaxy_tools-338dcccc8d8532a446fa60dc65092b5510c06e3a.tar.bz2 galaxy_tools-338dcccc8d8532a446fa60dc65092b5510c06e3a.zip |
Diffstat (limited to 'email.c')
-rw-r--r-- | email.c | 51 |
1 files changed, 1 insertions, 50 deletions
@@ -8,60 +8,11 @@ #include <sys/wait.h> +#include "util.h" #include "email.h" -static int daemonish (int nochdir, int noclose) -{ - pid_t pid; - int status; - - if (!nochdir && chdir ("/")) - return -1; - - if (!noclose) { - int fd, failed = 0; - - if ((fd = open ("/dev/null", O_RDWR)) < 0) return -1; - - if (dup2 (fd, 0) < 0 || dup2 (fd, 1) < 0 || dup2 (fd, 2) < 0) - failed++; - - if (fd > 2) close (fd); - - if (failed) return -1; - } - - switch ((pid = fork())) { - case 0: - break; - - case -1: - return -1; - - default: - waitpid (pid, &status, 0); - return 1;; - } - - if (setsid() < 0) return -1; - - switch (fork()) { - case 0: - break; - - case -1: - return -1; - - default: - _exit (0); - } - - return 0; -} - - static void write_complete (int fd, const void *_buf, size_t len) { ssize_t writ; |