From 02437bb365c17dfc3e642940e16e19eca8e0fd94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Mon, 27 Feb 2023 17:38:57 +0100 Subject: [PATCH] launch_local_testnet.sh: show which killed processes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit First step in debugging issue most probably re-introduced by: https://github.com/status-im/nimbus-eth2/pull/4551 Which causes the finalization tests script to kill other processes unrelated to the given CI job. Signed-off-by: Jakub SokoĊ‚owski --- scripts/launch_local_testnet.sh | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/scripts/launch_local_testnet.sh b/scripts/launch_local_testnet.sh index c389defaa..870fcaa16 100755 --- a/scripts/launch_local_testnet.sh +++ b/scripts/launch_local_testnet.sh @@ -738,26 +738,27 @@ cleanup() { # Avoid the trap enterring an infinite loop trap - SIGINT SIGTERM EXIT - for proc in "${PROCS_TO_KILL[@]}" - do - # TODO Previously, the code here used the '-P $$' option to limit - # the kill command only to children of this shell process. - # Unfortunately, this doesn't seem to work at the moment. - # Perhaps the child processes are not direct children of - # the current shell process? - pkill -f "$(basename "$proc")" || true + PKILL_ECHO_FLAG='-e' + if [[ "${OS}" == "macos" ]]; then + PKILL_ECHO_FLAG='-l' + fi + + echo "Terminating:" + for proc in "${PROCS_TO_KILL[@]}"; do + # FIXME We should be using '-P $$' here but it doesn't always work. + PROC_NAME=$(basename "$proc") + pkill -SIGTERM "${PKILL_ECHO_FLAG}" -f "${PROC_NAME}" \ + || echo "Nothing to terminate: ${PROC_NAME}" done sleep 2 - for proc in "${PROCS_TO_KILL[@]}" - do - # TODO Previously, the code here used the '-P $$' option to limit - # the kill command only to children of this shell process. - # Unfortunately, this doesn't seem to work at the moment. - # Perhaps the child processes are not direct children of - # the current shell process? - pkill -SIGKILL -f "$(basename "$proc")" || true + echo "Killing:" + for proc in "${PROCS_TO_KILL[@]}"; do + # FIXME We should be using '-P $$' here but it doesn't always work. + PROC_NAME=$(basename "$proc") + pkill -SIGKILL "${PKILL_ECHO_FLAG}" -f "${PROC_NAME}" \ + || echo "Nothing to kill: ${PROC_NAME}" done # Delete all binaries we just built, because these are unusable outside this