summaryrefslogtreecommitdiff
path: root/anytun.cpp
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2008-04-11 16:13:33 +0000
committerChristian Pointner <equinox@anytun.org>2008-04-11 16:13:33 +0000
commitce684962c9545499ee26aed97b0e63f0e98b9841 (patch)
treedc652340f1cf7a08b88077f5d343d8f2a73b5d62 /anytun.cpp
parentfixed issue with pid file and chrooting to early (diff)
fixed issue with closing to much files @ daemonize
Diffstat (limited to 'anytun.cpp')
-rw-r--r--anytun.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/anytun.cpp b/anytun.cpp
index b1279fb..9156de9 100644
--- a/anytun.cpp
+++ b/anytun.cpp
@@ -385,7 +385,8 @@ void daemonize()
// std::cout << "running in background now..." << std::endl;
int fd;
- for (fd=getdtablesize();fd>=0;--fd) // close all file descriptors
+// for (fd=getdtablesize();fd>=0;--fd) // close all file descriptors
+ for (fd=0;fd<=2;fd++) // close all file descriptors
close(fd);
fd=open("/dev/null",O_RDWR); // stdin
dup(fd); // stdout
@@ -428,6 +429,7 @@ int main(int argc, char* argv[])
chrootAndDrop(gOpt.getChrootDir(), gOpt.getUsername());
if(gOpt.getDaemonize())
daemonize();
+
if(pidFile.is_open()) {
pid_t pid = getpid();
pidFile << pid;