From ce684962c9545499ee26aed97b0e63f0e98b9841 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Fri, 11 Apr 2008 16:13:33 +0000 Subject: fixed issue with closing to much files @ daemonize --- anytun.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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; -- cgit v1.2.3