]> The Tcpdump Group git mirrors - tcpdump/commitdiff
child_cleanup: reap as many child processes as possible 972/head
authorDominique Martinet <[email protected]>
Fri, 21 Jan 2022 01:27:07 +0000 (10:27 +0900)
committerFrancois-Xavier Le Bail <[email protected]>
Wed, 19 Apr 2023 06:09:58 +0000 (08:09 +0200)
Under load it's possible multiple child processes have been killed before
we start processing the SIGCHILD signal, leaving zombie processes behind
everytime we miss a process.
Reap as many processes as possible instead of assuming one handler
call = one process like we currently did.

Can be reproduced by running the following commands in parallel:
 - tcpdump -i lo -w /tmp/test -C 1 -z /usr/bin/true
 - iperf3 -s
 - iperf3 -c localhost

tcpdump.c

index f092e161634e663ccff4aefdb44e61f25def2460..b0d3aa5bd6deb1de1edf579b8fbb4f5ac6494ada 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -2836,7 +2836,7 @@ cleanup(int signo _U_)
 static void
 child_cleanup(int signo _U_)
 {
-  wait(NULL);
+  while (waitpid(-1, NULL, WNOHANG) >= 0);
 }
 #endif /* HAVE_FORK && HAVE_VFORK */