Browse Source

wait_for_ping

main
pvincent 7 months ago
parent
commit
5bf228bb04
  1. 10
      tools/wait_for_ping

10
tools/wait_for_ping

@ -0,0 +1,10 @@
#!/bin/bash
ping_cancelled=false # Keep track of whether the loop was cancelled, or succeeded
until ping -w1 -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"
Loading…
Cancel
Save