Make main work block async

Closes #59.
This commit is contained in:
Chris Down 2018-02-19 15:04:52 +00:00
parent eb7d2b9481
commit 11304d3a60

View file

@ -10,7 +10,7 @@ major_version=4
cache_dir=$CM_DIR/clipmenu.$major_version.$USER/
cache_file=$cache_dir/line_cache
lock_file=$cache_dir/lock
lock_timeout=2
lock_timeout=5
has_clipnotify=0
xsel_log=/dev/null
@ -120,6 +120,7 @@ while true; do
fi
fi
{
if ! flock -x -w "$lock_timeout" "$lock_fd"; then
if (( CM_ONESHOT )); then
printf 'ERROR: %s\n' 'Timed out waiting for lock' >&2
@ -176,8 +177,10 @@ while true; do
done
flock -u "$lock_fd"
} &
if (( CM_ONESHOT )); then
wait
debug 'Oneshot mode enabled, exiting'
break
fi