1
0
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:
fumiama
2021-02-16 12:49:45 +08:00
parent fc5f4592fe
commit d5f513eb56
2 changed files with 8 additions and 6 deletions

BIN
server

Binary file not shown.

View File

@@ -186,12 +186,14 @@ int main(int argc, char *argv[]) {
int times = 0;
sscanf(argv[2], "%d", &times);
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);
}