mirror of
https://github.com/fumiama/simple-dict.git
synced 2026-06-08 20:10:24 +08:00
add daemon
This commit is contained in:
14
server.c
14
server.c
@@ -186,12 +186,14 @@ int main(int argc, char *argv[]) {
|
||||
int times = 0;
|
||||
sscanf(argv[2], "%d", ×);
|
||||
if(times > 0) {
|
||||
fp = NULL;
|
||||
fp = fopen(argv[3], "rb+");
|
||||
if(!fp) fp = fopen(argv[3], "wb+");
|
||||
if(fp) {
|
||||
if(bindServer(port, times)) if(listenSocket(times)) while(1) acceptClient();
|
||||
} else fprintf(stderr, "Error opening dict file: %s\n", argv[3]);
|
||||
if(daemon(1, 1) >= 0) {
|
||||
fp = NULL;
|
||||
fp = fopen(argv[3], "rb+");
|
||||
if(!fp) fp = fopen(argv[3], "wb+");
|
||||
if(fp) {
|
||||
if(bindServer(port, times)) if(listenSocket(times)) while(1) acceptClient();
|
||||
} else fprintf(stderr, "Error opening dict file: %s\n", argv[3]);
|
||||
} else perror("Start daemon error");
|
||||
} else fprintf(stderr, "Error times: %d\n", times);
|
||||
} else fprintf(stderr, "Error port: %d\n", port);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user