From: Matthias Kruk Date: Tue, 20 Apr 2021 23:24:39 +0000 (+0900) Subject: include/mutex: Make mutex_lock() fail if the path does not exist X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=7af7283f56eb96d5604bc8d7648639ab935258ad;p=toolbox include/mutex: Make mutex_lock() fail if the path does not exist The mutex_lock() function does not check if the path of the mutex exists, causing it to wait forever if an invalid path was passed. This commit makes mutex_lock() fail if it could not inotifywait on the directory that contains the mutex. --- diff --git a/include/mutex.sh b/include/mutex.sh index edc4da7..01f67ac 100644 --- a/include/mutex.sh +++ b/include/mutex.sh @@ -27,7 +27,9 @@ mutex_lock() { lock="$1" while ! mutex_trylock "$lock"; do - inotifywait -qq "${lock%/*}" + if ! inotifywait -qq "${lock%/*}"; then + return 1 + fi done return 0