summaryrefslogtreecommitdiff
path: root/anytun.cpp
diff options
context:
space:
mode:
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;