summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominique Martinet <dominique.martinet@atmark-techno.com>2022-01-21 10:27:07 +0900
committerFrancois-Xavier Le Bail <devel.fx.lebail@orange.fr>2023-04-19 08:09:58 +0200
commitb5f0be2196d897c76144a5b90b168836df54d6fa (patch)
treecd39c78b8f845185971286e09464050d123d7e53
parent89b68e1a5fe131951858d7bcf71587ad7fa25846 (diff)
downloadtcpdump-b5f0be2196d897c76144a5b90b168836df54d6fa.tar.gz
child_cleanup: reap as many child processes as possible
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
-rw-r--r--tcpdump.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tcpdump.c b/tcpdump.c
index f092e161..b0d3aa5b 100644
--- 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 */