From 48b40a53b0746848d5c8ea881d319e6120c76d40 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Sat, 13 Apr 2019 22:23:07 -0400 Subject: src/main.sh: Move _lock() and _unlock() And fix an _unlock() call. --- diff --git a/src/main.sh b/src/main.sh index e56c076..3a67c84 100644 --- a/src/main.sh +++ b/src/main.sh @@ -41,12 +41,26 @@ conf_key= lock= exit_status= +_lock() +{ + mkdir -p "${base_dir}/.db" + lock="${base_dir}/.db/lock" + if ! (set -C; printf '%d\n' "${$}" >"${lock}") 2>/dev/null; then + error 2 "$(get_msg 'lock_fail')" + fi +} + +_unlock() +{ + rm -f "${lock}" +} + _handle_sig() { local sig="${1}" shift 1 - unlock + _unlock if [ "x${exit_status:+set}" = 'xset' ]; then exit ${exit_status} @@ -90,15 +104,6 @@ _get_options() return 0 } -_lock() -{ - mkdir -p "${base_dir}/.db" - lock="${base_dir}/.db/lock" - if ! (set -C; printf '%d\n' "${$}" >"${lock}") 2>/dev/null; then - error 2 "$(get_msg 'lock_fail')" - fi -} - _get_conf() { local old_dir= @@ -134,11 +139,6 @@ init() _get_conf } -_unlock() -{ - rm -f "${lock}" -} - fini() { update_feeds -- cgit v0.9.1