diff options
author | Jouke Witteveen <j.witteveen@gmail.com> | 2012-06-21 12:19:53 +0200 |
---|---|---|
committer | Jouke Witteveen <j.witteveen@gmail.com> | 2012-06-21 12:19:53 +0200 |
commit | 5ac724b8d139b7e38c3a16c8752bad55076ea670 (patch) | |
tree | b7d5cdb68c5e050829aa6de401224284c0b482c0 /src/globals | |
parent | 4e034777fa0bfffa11d87b602e6b2b941edd3262 (diff) | |
download | netctl-5ac724b8d139b7e38c3a16c8752bad55076ea670.tar.gz netctl-5ac724b8d139b7e38c3a16c8752bad55076ea670.tar.xz |
Introduce polling timeout logic
This should fix FS#30361 along the way.
Diffstat (limited to 'src/globals')
-rw-r--r-- | src/globals | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/globals b/src/globals index 0d573e2..af411fe 100644 --- a/src/globals +++ b/src/globals @@ -95,6 +95,20 @@ function checkyesno() { } +## Waits until a statement succeeds or a timeout occurs +# $1: timeout in seconds +# $2...: condition command +function timeout_wait() { + local timeout="$1" + shift + while ! eval "$*"; do + (( timeout-- > 0 )) || return 1 + sleep 1 + done + return 0 +} + + ### Load all +x files in $HOOKS_DIR function load_hooks() { local hook |