Let user exit program, while acquiring lock

This commit is contained in:
Fierelier 2024-02-17 09:54:39 +01:00
parent 8ebad1735b
commit 4ab2192d16
2 changed files with 4 additions and 0 deletions

View File

@ -10,9 +10,11 @@ mkdir -p "/run/$APP_NAME"
exec 100>"/run/$APP_NAME/lock"
set +e
while true; do
source "$APP_DIR/cmd/trap"
if flock -e -n 100; then
break
fi
source "$APP_DIR/cmd/untrap"
sleep 1
done

2
app/cmd/untrap Normal file
View File

@ -0,0 +1,2 @@
#!/usr/bin/env bash
trap - SIGINT SIGTERM SIGQUIT SIGHUP