src/server/daemon/main.c

changeset 115
51d9a15eac98
parent 86
49bb6c8ceb2b
child 125
c913d515be1e
--- a/src/server/daemon/main.c	Wed Feb 10 12:19:56 2016 +0100
+++ b/src/server/daemon/main.c	Sat Oct 22 11:27:39 2016 +0200
@@ -46,7 +46,8 @@
 
 #include "configmanager.h"
 
-int std_pipe_fds[2];
+static int std_pipe_fds[2];
+static WSBool is_daemon;
 
 void test() {
     time_t t = time(NULL);
@@ -55,6 +56,11 @@
     printf("%s\n", date.ptr);
 }
 
+
+WSBool main_is_daemon(void) {
+    return is_daemon;
+}
+
 /*
  * SIGUSR1: reload the configuration files
  */
@@ -97,15 +103,15 @@
     //test();
     
     /* if the -c parameter is specified, we don't create a daemon */
-    int d = 1;
+    is_daemon = 1;
     for(int i=0;i<argc;i++) {
         char *p = argv[i];
         if(p[0] == '-' && p[1] == 'c') {
-            d = 0;
+            is_daemon = 0;
             break;
         }
     }
-    if(d) {
+    if(is_daemon) {
         /* create daemon */
         pid_t pid = fork();
         if(pid < 0) {
@@ -163,7 +169,7 @@
      
     /* TODO: join threads (or not?) */
     while(1) {
-        if(d) {
+        if(is_daemon) {
             fflush(stdout);
             fflush(stderr);
         }

mercurial