Handle missing flock

If flock is not installed, fall back to the thread-unsafe version.
pull/61/head
v9v 2019-07-05 19:33:12 +02:00 committed by GitHub
parent 721890d22f
commit 10e612d72c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -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