From 0c165c4126f7bc10dd2177bd9f2400c019428efd Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Fri, 7 Nov 2025 13:58:10 +0100 Subject: [PATCH 1/1] --- pingwait.sh | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 pingwait.sh diff --git a/pingwait.sh b/pingwait.sh new file mode 100644 index 0000000..82e430e --- /dev/null +++ b/pingwait.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# wait until a host is pingable, then exit + +ping_cancelled=false # Keep track of whether the loop was cancelled, or succeeded +until ping -c1 "$1" >/dev/null 2>&1; do :; done & # The "&" backgrounds it +trap "kill $!; ping_cancelled=true" SIGINT +wait $! # Wait for the loop to exit, one way or another +trap - SIGINT # Remove the trap, now we're done with it +echo "Done pinging, cancelled=$ping_cancelled" -- 2.30.2