summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2019-04-25 20:58:13 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2019-04-25 20:58:13 (EDT)
commit0f5dc89d0772eba2d1a06a57a7d3aeb69146a5a2 (patch)
tree78a82e98155b6e393926443094c42d08b877f130
parentdd391ea7729c2d48ce7abbd65c2eb01b0b9c428c (diff)
_mutex_trylock(), mutex_is_unlockable(): Make "set -e"-safe
-rw-r--r--src/mutex.sh10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/mutex.sh b/src/mutex.sh
index 4aa8e1f..be63d96 100644
--- a/src/mutex.sh
+++ b/src/mutex.sh
@@ -22,9 +22,8 @@ _mutex_trylock()
{
local mutex="${1}"
- (set -C; printf '%d\n' "${$}" >"${mutex}") 2>/dev/null
-
- return ${?}
+ (set -C; printf '%d\n' "${$}" >"${mutex}") 2>/dev/null || return ${?}
+ return 0
}
mutex_timedlock()
@@ -52,7 +51,6 @@ mutex_is_unlockable()
{
local mutex="${1}"
- [ "x$(cat "${mutex}" 2>/dev/null)" = "x${$}" ]
-
- return ${?}
+ [ "x$(cat "${mutex}" 2>/dev/null)" = "x${$}" ] || return ${?}
+ return 0
}