mirror of
https://github.com/fumiama/simple-http-server.git
synced 2026-06-09 12:30:34 +08:00
修复作为daemon失败
This commit is contained in:
2
server.c
2
server.c
@@ -541,6 +541,8 @@ int main(int argc, char **argv) {
|
|||||||
printf("httpd running on port %d\n", port);
|
printf("httpd running on port %d\n", port);
|
||||||
if(as_daemon) {
|
if(as_daemon) {
|
||||||
pid = fork();
|
pid = fork();
|
||||||
|
if(pid == 0) pid = fork();
|
||||||
|
else return 0;
|
||||||
while (pid > 0) { //主进程监控子进程状态,如果子进程异常终止则重启之
|
while (pid > 0) { //主进程监控子进程状态,如果子进程异常终止则重启之
|
||||||
wait(NULL);
|
wait(NULL);
|
||||||
puts("Server subprocess exited. Restart...");
|
puts("Server subprocess exited. Restart...");
|
||||||
|
|||||||
Reference in New Issue
Block a user