equal
deleted
inserted
replaced
17 #include <stdlib.h> |
17 #include <stdlib.h> |
18 #include <unistd.h> |
18 #include <unistd.h> |
19 #include <limits.h> |
19 #include <limits.h> |
20 #include <signal.h> |
20 #include <signal.h> |
21 #include <fcntl.h> |
21 #include <fcntl.h> |
|
22 #include <libgen.h> |
22 |
23 |
23 #include <stdio.h> |
24 #include <stdio.h> |
24 |
25 |
25 #include "main.h" |
26 #include "main.h" |
26 |
27 |
149 void server_main(int notify_fd, char *_path) |
150 void server_main(int notify_fd, char *_path) |
150 { |
151 { |
151 int ls; |
152 int ls; |
152 struct sockaddr_un addr; |
153 struct sockaddr_un addr; |
153 int res; |
154 int res; |
|
155 char *dirpath; |
154 |
156 |
155 process_type = SERVER; |
157 process_type = SERVER; |
156 max_descriptors = get_max_descriptors(); |
158 max_descriptors = get_max_descriptors(); |
157 |
159 |
158 path = _path; |
160 path = _path; |
|
161 |
|
162 /* Move the server to the socket directory */ |
|
163 dirpath = strdup(path); |
|
164 chdir(dirname(dirpath)); |
|
165 free(dirpath); |
159 |
166 |
160 nconnections = 0; |
167 nconnections = 0; |
161 |
168 |
162 ls = socket(AF_UNIX, SOCK_STREAM, 0); |
169 ls = socket(AF_UNIX, SOCK_STREAM, 0); |
163 if(ls == -1) |
170 if(ls == -1) |