From ba2886fcd14423f250fa3065a9bcf9a6ac15453c Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 24 Mar 2026 20:38:45 +0100 Subject: [PATCH] nbd-server: drop the double-fork ... as this breaks as systemd service: This is of type 'forking', so the (first) fork becomes the main and controlling process. The second fork makes the main process exit, and the service is stopped. Calling setsid() should be sufficient to detatch from terminal. Closes: https://github.com/NetworkBlockDevice/nbd/issues/182 --- nbd-server.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/nbd-server.c b/nbd-server.c index 6a87d445..b77429ba 100644 --- a/nbd-server.c +++ b/nbd-server.c @@ -3816,12 +3816,6 @@ void daemonize() { if(dup2(2, newfd) < 0) { err("dup2 stderr"); } - child=fork(); - if(child < 0) { - err("fork"); - } else if(child > 0) { - exit(EXIT_SUCCESS); - } FILE*pidf=fopen(pidfname, "w"); if(pidf) { fprintf(pidf,"%d\n", (int)getpid());