From 5ac724b8d139b7e38c3a16c8752bad55076ea670 Mon Sep 17 00:00:00 2001 From: Jouke Witteveen Date: Thu, 21 Jun 2012 12:19:53 +0200 Subject: Introduce polling timeout logic This should fix FS#30361 along the way. --- src/globals | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/globals') 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 -- cgit v1.2.3-24-g4f1b