From 10e612d72c49c5c8762cca4fd17c864b3f373f70 Mon Sep 17 00:00:00 2001 From: v9v <36771847+v9v@users.noreply.github.com> Date: Fri, 5 Jul 2019 19:33:12 +0200 Subject: [PATCH] Handle missing flock If flock is not installed, fall back to the thread-unsafe version. --- scripts/continuum_save.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/continuum_save.sh b/scripts/continuum_save.sh index 29b24ac..e8c3287 100755 --- a/scripts/continuum_save.sh +++ b/scripts/continuum_save.sh @@ -36,7 +36,9 @@ fetch_and_run_tmux_resurrect_save_script() { main() { ( - flock -n 101 || return # The code below is not thread-safe. + # The code after "flock" is not thread-safe. A race condition can be triggered by multiple + # tmux clients performing autosave in parallel. + ! command -v flock || flock -n 101 || return if supported_tmux_version_ok && auto_save_not_disabled && enough_time_since_last_run_passed; then fetch_and_run_tmux_resurrect_save_script fi