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:
14
server.c
14
server.c
@@ -186,12 +186,14 @@ int main(int argc, char *argv[]) {
|
|||||||
int times = 0;
|
int times = 0;
|
||||||
sscanf(argv[2], "%d", ×);
|
sscanf(argv[2], "%d", ×);
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user