summaryrefslogtreecommitdiff
path: root/src/posix/posixDaemon.cpp
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2010-02-16 22:26:06 +0000
committerChristian Pointner <equinox@anytun.org>2010-02-16 22:26:06 +0000
commitfb886c8248d7d01f86f831fab9887e730d33ea6f (patch)
tree50ea62679521188b16663f3a6227aff5d033ac62 /src/posix/posixDaemon.cpp
parentmalloc/free vs new at posix sysexec (diff)
allegedly-release-friendly dirty dirty dirty hack (concerning pids)
Diffstat (limited to 'src/posix/posixDaemon.cpp')
-rw-r--r--src/posix/posixDaemon.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/posix/posixDaemon.cpp b/src/posix/posixDaemon.cpp
index 4b4f63b..e4a4148 100644
--- a/src/posix/posixDaemon.cpp
+++ b/src/posix/posixDaemon.cpp
@@ -97,9 +97,13 @@ void DaemonService::chroot(std::string const& chrootdir)
AnytunError::throwErr() << "can't change to /";
}
+/// TODO: this outstandignly ugly please and i really can't stress the please fix it asap!!!!!!!
+
+std::ofstream pidFile; // FIXXXME no global variable
+
void DaemonService::daemonize()
{
- std::ofstream pidFile;
+// std::ofstream pidFile;
if(gOpt.getPidFile() != "") {
pidFile.open(gOpt.getPidFile().c_str());
if(!pidFile.is_open())
@@ -143,14 +147,15 @@ void DaemonService::daemonize()
if(dup(fd) == -1) // stderr
cLog.msg(Log::PRIO_WARNING) << "can't open /dev/null as stderr";
}
+
+// FIXXXXME: write this pid to file (currently pid from posix/signhandler.hpp:77 is used)
+//
+// if(pidFile.is_open()) {
+// pid_t pid = getpid();
+// pidFile << pid;
+// pidFile.close();
+// }
- if(pidFile.is_open()) {
- pid_t pid = getpid();
- pidFile << pid;
- pidFile.close();
- }
-
- setpgid(0, 0);
daemonized_ = true;
}