--- ctrlproxy-3.0.8.orig/src/main.c Sat Dec 6 12:36:34 2008
+++ ctrlproxy-3.0.8/src/main.c Wed Oct 7 15:27:42 2009
@@ -322,7 +322,7 @@
}
if (isdaemon) {
-#ifdef HAVE_DAEMON
+#if defined(HAVE_DAEMON) || defined(HAVE_FORK)
#ifdef SIGTTOU
signal(SIGTTOU, SIG_IGN);
#endif
--- ctrlproxy-3.0.8.orig/lib/util.c Sat Dec 6 12:36:33 2008
+++ ctrlproxy-3.0.8/lib/util.c Wed Oct 7 15:29:11 2009
@@ -26,6 +26,13 @@
#include <fcntl.h>
#include <glib/gstdio.h>
+#ifndef HAVE_DAEMON
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#endif
+
static inline int str_cmphelper(const char *a, const char *b, char sh, char sl, char eh, char el)
{
int i;
@@ -152,3 +159,41 @@
return len - inbytes_left;
}
+#ifndef HAVE_DAEMON
+#ifdef HAVE_FORK
+int daemon(int nochdir, int noclose)
+{
+ int fd, i;
+
+ switch (fork()) {
+ case 0:
+ break;
+ case -1:
+ return -1;
+ default:
+ _exit(0);
+ }
+
+ if (!nochdir) {
+ chdir("/");
+ }
+
+ if (setsid() < 0) {
+ return -1;
+ }
+
+ if (!noclose) {
+ if ((fd = open("/dev/null", O_RDWR)) >= 0) {
+ for (i = 0; i < 3; i++) {
+ dup2(fd, i);
+ }
+ if (fd > 2) {
+ close(fd);
+ }
+ }
+ }
+
+ return 0;
+}
+#endif
+#endif
--- ctrlproxy-3.0.8.orig/daemon/main.c Sat Dec 6 12:36:33 2008
+++ ctrlproxy-3.0.8/daemon/main.c Wed Oct 7 15:27:09 2009
@@ -491,7 +491,7 @@
}
if (isdaemon) {
-#ifdef HAVE_DAEMON
+#if defined(HAVE_DAEMON) || defined(HAVE_FORK)
#ifdef SIGTTOU
signal(SIGTTOU, SIG_IGN);
#endif