git.cweiske.de
/
paste
/
941.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(initial)
(no commit message)
master
author
Christian Weiske
<cweiske@cweiske.de>
Fri, 7 Nov 2025 12:58:10 +0000
(13:58 +0100)
committer
Christian Weiske
<cweiske@cweiske.de>
Fri, 7 Nov 2025 12:58:10 +0000
(13:58 +0100)
pingwait.sh
[new file with mode: 0644]
patch
|
blob
diff --git a/pingwait.sh
b/pingwait.sh
new file mode 100644
(file)
index 0000000..
82e430e
--- /dev/null
+++ b/
pingwait.sh
@@ -0,0
+1,9
@@
+#!/bin/bash
\r
+# wait until a host is pingable, then exit
\r
+
\r
+ping_cancelled=false # Keep track of whether the loop was cancelled, or succeeded
\r
+until ping -c1 "$1" >/dev/null 2>&1; do :; done & # The "&" backgrounds it
\r
+trap "kill $!; ping_cancelled=true" SIGINT
\r
+wait $! # Wait for the loop to exit, one way or another
\r
+trap - SIGINT # Remove the trap, now we're done with it
\r
+echo "Done pinging, cancelled=$ping_cancelled"
\r