From: Christian Weiske Date: Fri, 7 Nov 2025 12:58:10 +0000 (+0100) Subject: (no commit message) X-Git-Url: https://git.cweiske.de/paste/941.git/commitdiff_plain/HEAD --- 0c165c4126f7bc10dd2177bd9f2400c019428efd 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"