1
0
mirror of https://github.com/fumiama/simple-dict.git synced 2026-06-30 08:50:25 +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; int times = 0;
sscanf(argv[2], "%d", &times); sscanf(argv[2], "%d", &times);
if(times > 0) { if(times > 0) {
fp = NULL; if(daemon(1, 1) >= 0) {
fp = fopen(argv[3], "rb+"); fp = NULL;
if(!fp) fp = fopen(argv[3], "wb+"); fp = fopen(argv[3], "rb+");
if(fp) { if(!fp) fp = fopen(argv[3], "wb+");
if(bindServer(port, times)) if(listenSocket(times)) while(1) acceptClient(); if(fp) {
} else fprintf(stderr, "Error opening dict file: %s\n", argv[3]); 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 times: %d\n", times);
} else fprintf(stderr, "Error port: %d\n", port); } else fprintf(stderr, "Error port: %d\n", port);
} }