sxmo_daemons: only run one process at a time
There seems to be a race somewhere in sxmo_demons that can cause it to spawn multiple copies of a task. This patch does the equivalent of using sxmo_uniq_exec, but it doesn't require changing all the calls to sxmo_daemons. Signed-off-by: Willow Barraco <contact@willowbarraco.fr>
This commit is contained in:
@@ -4,11 +4,14 @@
|
||||
|
||||
# include common definitions
|
||||
# shellcheck source=scripts/core/sxmo_common.sh
|
||||
. "$(dirname "$0")/sxmo_common.sh"
|
||||
. sxmo_common.sh
|
||||
|
||||
ROOT="$XDG_RUNTIME_DIR/sxmo_daemons"
|
||||
mkdir -p "$ROOT"
|
||||
|
||||
exec 3<> "$ROOT/daemons.lock"
|
||||
flock -x 3
|
||||
|
||||
list() {
|
||||
find "$ROOT" -mindepth 1 -exec 'basename' '{}' ';'
|
||||
}
|
||||
@@ -79,8 +82,13 @@ start() {
|
||||
fi
|
||||
|
||||
sxmo_debug "start $id"
|
||||
"$@" &
|
||||
printf "%s\n" "$!" > "$ROOT"/"$id"
|
||||
(
|
||||
# We need a subshell so we can close the lock fd, without
|
||||
# releasing the lock
|
||||
exec 3<&-
|
||||
"$@" &
|
||||
printf "%s\n" "$!" > "$ROOT"/"$id"
|
||||
)
|
||||
}
|
||||
|
||||
running() {
|
||||
|
Reference in New Issue
Block a user