summaryrefslogtreecommitdiff
path: root/src/daemon.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon.cc')
-rw-r--r--src/daemon.cc24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/daemon.cc b/src/daemon.cc
index 154385c1..60be5bb3 100644
--- a/src/daemon.cc
+++ b/src/daemon.cc
@@ -45,33 +45,35 @@ int daemon(int nochdir, int noclose)
#ifdef HAVE_WORKING_FORK
pid_t pid;
pid = fork();
- if(pid == -1) {
+ if (pid == -1) {
return -1;
- } else if(pid > 0) {
+ }
+ else if (pid > 0) {
_exit(EXIT_SUCCESS);
}
- if(setsid() == -1) {
+ if (setsid() == -1) {
return -1;
}
pid = fork();
- if(pid == -1) {
+ if (pid == -1) {
return -1;
- } else if(pid > 0) {
+ }
+ else if (pid > 0) {
_exit(EXIT_SUCCESS);
}
- if(nochdir == 0) {
- if(chdir("/") == -1) {
+ if (nochdir == 0) {
+ if (chdir("/") == -1) {
return -1;
}
}
- if(noclose == 0) {
- if(freopen("/dev/null", "r", stdin) == nullptr) {
+ if (noclose == 0) {
+ if (freopen("/dev/null", "r", stdin) == nullptr) {
return -1;
}
- if(freopen("/dev/null", "w", stdout) == nullptr) {
+ if (freopen("/dev/null", "w", stdout) == nullptr) {
return -1;
}
- if(freopen("/dev/null", "w", stderr) == nullptr) {
+ if (freopen("/dev/null", "w", stderr) == nullptr) {
return -1;
}
}