From cd44d1bd683f5aff48e74574bc43993b89bd8fea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Mon, 7 Jun 2021 22:15:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BD=9C=E4=B8=BAdaemon?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server.c b/server.c index 504bdd2..b48e210 100644 --- a/server.c +++ b/server.c @@ -541,6 +541,8 @@ int main(int argc, char **argv) { printf("httpd running on port %d\n", port); if(as_daemon) { pid = fork(); + if(pid == 0) pid = fork(); + else return 0; while (pid > 0) { //主进程监控子进程状态,如果子进程异常终止则重启之 wait(NULL); puts("Server subprocess exited. Restart...");