about summary refs log tree commit diff
path: root/nitro.c
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2024-02-08 14:56:14 +0100
committerLeah Neukirchen <leah@vuxu.org>2024-02-08 15:27:30 +0100
commit344154197ddc6c23ab7b0a5e577d0a5dd8790676 (patch)
tree2153e77705094e8ffbd0595ffe77eadfcacb06d5 /nitro.c
parentdebf0231cb0af5f1fe06399a1bca7f84055acb3a (diff)
downloadnitro-344154197ddc6c23ab7b0a5e577d0a5dd8790676.tar.gz
nitro-344154197ddc6c23ab7b0a5e577d0a5dd8790676.tar.xz
nitro-344154197ddc6c23ab7b0a5e577d0a5dd8790676.zip
reap after SIGKILL again
Strictly speaking not needed, but I think it may case the filesystems
to remain EBUSY.

Also, when running in a container we don't want to leak zombies to the
outside (found out by skarnet).

We need the alarm and blocking waitpid, since it's possible (in theory)
no process has exited between the kill and first call of waitpid(-1, 0,
WNOHANG).
Diffstat (limited to 'nitro.c')
-rw-r--r--nitro.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/nitro.c b/nitro.c
index ac8aaae..545ea15 100644
--- a/nitro.c
+++ b/nitro.c
@@ -1558,6 +1558,14 @@ main(int argc, char *argv[])
 
 		prn(2, "- nitro: sending SIGKILL to all processes\n");
 		kill(-1, SIGKILL);
+
+		alarm(1);
+		while (1) {
+			int r = waitpid(-1, 0, 0);
+			if (r < 0)
+				break;
+		}
+		alarm(0);
 	}
 	if (real_pid1) {
 		prn(2, "- nitro: system %s\n",