From 7af7283f56eb96d5604bc8d7648639ab935258ad Mon Sep 17 00:00:00 2001 From: Matthias Kruk Date: Wed, 21 Apr 2021 08:24:39 +0900 Subject: [PATCH] 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. --- include/mutex.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 -- 2.47.3