From 847bee79d77df86299bb5ac909b15b22ad221bd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucio=20Andr=C3=A9s=20Illanes=20Albornoz?= Date: Thu, 19 Mar 2020 11:44:23 +0000 Subject: subr/{pkg_install,rtl_fetch}.subr, subr/rtl_complex.subr:rtl_flock_acquire(): split. --- subr/rtl_complex.subr | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'subr/rtl_complex.subr') diff --git a/subr/rtl_complex.subr b/subr/rtl_complex.subr index 2ce5dd16..8aa59bec 100644 --- a/subr/rtl_complex.subr +++ b/subr/rtl_complex.subr @@ -95,6 +95,19 @@ rtl_filter_vars() { printf "%s" "${_vars}"; }; +rtl_flock_acquire() { + local _fd="${1}" _conflict_exit_code="${2:-622}" _wait="${3:-3600}" + while true; do + if flock -E "${_conflict_exit_code}" -w "${_wait}" "${_fd}"; then + break; + elif [ "${?}" -eq "${_conflict_exit_code}" ]; then + continue; + else + return "${?}"; + fi; + done; +}; + rtl_get_cpu_count() { local _line="" _ncpus=0 _rc=0 _sname="$(uname -s 2>/dev/null)"; _status=""; case "${_sname}" in -- cgit v1.2.3