traffic fix
All checks were successful
Build and Deploy MITM Webserver / build (push) Successful in 9s

This commit is contained in:
2026-03-07 17:06:04 +01:00
parent 13cc2612a2
commit 1fdf6ae3b9

View File

@@ -18,6 +18,7 @@ IPERF_UDP_PORT=5202
STOP=0
MAIN_PID=$$
KEYPRESS_PID=""
ACTIVE_PID=""
usage() {
cat <<USAGE
@@ -96,8 +97,14 @@ start_keypress_listener() {
}
cleanup() {
STOP=1
if [[ -n "$ACTIVE_PID" ]]; then
kill_command_group "$ACTIVE_PID"
ACTIVE_PID=""
fi
if [[ -n "$KEYPRESS_PID" ]]; then
kill "$KEYPRESS_PID" >/dev/null 2>&1 || true
wait "$KEYPRESS_PID" >/dev/null 2>&1 || true
fi
}
@@ -105,20 +112,38 @@ on_interrupt() {
STOP=1
}
kill_command_group() {
local pid="$1"
if [[ -z "$pid" ]]; then
return
fi
kill -TERM -- "-$pid" >/dev/null 2>&1 || kill "$pid" >/dev/null 2>&1 || true
sleep 0.1
kill -KILL -- "-$pid" >/dev/null 2>&1 || kill -KILL "$pid" >/dev/null 2>&1 || true
}
run_interruptible() {
"$@" &
if has_cmd setsid; then
setsid "$@" &
else
"$@" &
fi
local pid=$!
ACTIVE_PID="$pid"
while kill -0 "$pid" >/dev/null 2>&1; do
if [[ "$STOP" -eq 1 ]]; then
kill "$pid" >/dev/null 2>&1 || true
kill_command_group "$pid"
wait "$pid" >/dev/null 2>&1 || true
ACTIVE_PID=""
return 130
fi
sleep 0.1
done
wait "$pid" >/dev/null 2>&1 || true
ACTIVE_PID=""
return 0
}