44 #include "httprequest.h" |
44 #include "httprequest.h" |
45 #include "httplistener.h" |
45 #include "httplistener.h" |
46 |
46 |
47 #include "configmanager.h" |
47 #include "configmanager.h" |
48 |
48 |
49 int std_pipe_fds[2]; |
49 static int std_pipe_fds[2]; |
|
50 static WSBool is_daemon; |
50 |
51 |
51 void test() { |
52 void test() { |
52 time_t t = time(NULL); |
53 time_t t = time(NULL); |
53 pool_handle_t *pool = pool_create(); |
54 pool_handle_t *pool = pool_create(); |
54 sstr_t date = date_format_http(t, pool); |
55 sstr_t date = date_format_http(t, pool); |
55 printf("%s\n", date.ptr); |
56 printf("%s\n", date.ptr); |
|
57 } |
|
58 |
|
59 |
|
60 WSBool main_is_daemon(void) { |
|
61 return is_daemon; |
56 } |
62 } |
57 |
63 |
58 /* |
64 /* |
59 * SIGUSR1: reload the configuration files |
65 * SIGUSR1: reload the configuration files |
60 */ |
66 */ |
95 |
101 |
96 int main(int argc, char **argv) { |
102 int main(int argc, char **argv) { |
97 //test(); |
103 //test(); |
98 |
104 |
99 /* if the -c parameter is specified, we don't create a daemon */ |
105 /* if the -c parameter is specified, we don't create a daemon */ |
100 int d = 1; |
106 is_daemon = 1; |
101 for(int i=0;i<argc;i++) { |
107 for(int i=0;i<argc;i++) { |
102 char *p = argv[i]; |
108 char *p = argv[i]; |
103 if(p[0] == '-' && p[1] == 'c') { |
109 if(p[0] == '-' && p[1] == 'c') { |
104 d = 0; |
110 is_daemon = 0; |
105 break; |
111 break; |
106 } |
112 } |
107 } |
113 } |
108 if(d) { |
114 if(is_daemon) { |
109 /* create daemon */ |
115 /* create daemon */ |
110 pid_t pid = fork(); |
116 pid_t pid = fork(); |
111 if(pid < 0) { |
117 if(pid < 0) { |
112 return EXIT_FAILURE; |
118 return EXIT_FAILURE; |
113 } else if(pid > 0) { |
119 } else if(pid > 0) { |