Stop the update sleep inhibitor without a signal error (#13361)
Stopping stay-awake sends TERM to the held process, which was an exec'd sleep. systemd-inhibit reports a child killed by a signal as an error, so every update ended with "'/usr/bin/setpriv' terminated by signal TERM." The held process now stays a shell that traps TERM, kills its sleep, and exits cleanly. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e1614f2bdb
commit
8cd727dfdf
2 files changed
+8
-6
No files matched your search
@@ -468,8 +468,9 @@ start_locked() {
|
|||||||
trap cleanup_pending_launch EXIT
|
trap cleanup_pending_launch EXIT
|
||||||
atomic_write_state "$launch_control_file" "active $token" || return 1
|
atomic_write_state "$launch_control_file" "active $token" || return 1
|
||||||
|
|
||||||
# The child is identifiable before it publishes state, including before exec.
|
# The child is identifiable by the token in its arguments from the moment it
|
||||||
# exec -a retains that identity without keeping an extra shell alive.
|
# starts. It stays a shell so stop's TERM ends it with a clean exit, since
|
||||||
|
# systemd-inhibit reports a child killed by a signal as an error.
|
||||||
local hold_command=(
|
local hold_command=(
|
||||||
/usr/bin/systemd-inhibit --what=sleep:idle --who=omarchy-update
|
/usr/bin/systemd-inhibit --what=sleep:idle --who=omarchy-update
|
||||||
--why="Omarchy update in progress [$token]" --mode=block
|
--why="Omarchy update in progress [$token]" --mode=block
|
||||||
@@ -481,7 +482,6 @@ start_locked() {
|
|||||||
token=$2
|
token=$2
|
||||||
owner=$3
|
owner=$3
|
||||||
control=$4
|
control=$4
|
||||||
expected="--why=Omarchy update in progress [$token]"
|
|
||||||
temporary=""
|
temporary=""
|
||||||
cleanup() { [[ -z $temporary ]] || /usr/bin/rm -f -- "$temporary"; }
|
cleanup() { [[ -z $temporary ]] || /usr/bin/rm -f -- "$temporary"; }
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
@@ -500,7 +500,9 @@ start_locked() {
|
|||||||
/usr/bin/flock -u "$control_fd"
|
/usr/bin/flock -u "$control_fd"
|
||||||
exec {control_fd}>&-
|
exec {control_fd}>&-
|
||||||
trap - EXIT
|
trap - EXIT
|
||||||
exec -a "$expected" /usr/bin/sleep infinity
|
trap "kill \$!; exit 0" TERM
|
||||||
|
/usr/bin/sleep infinity &
|
||||||
|
wait
|
||||||
' "--why=Omarchy update in progress [$token]" "$state_dir" "$token" "$caller_uid" "$launch_control_file"
|
' "--why=Omarchy update in progress [$token]" "$state_dir" "$token" "$caller_uid" "$launch_control_file"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -446,8 +446,8 @@ pause = ': >"$TEST_CANCEL_READY"; while :; do /usr/bin/sleep 0.02; done'
|
|||||||
if sys.argv[2] == 'published':
|
if sys.argv[2] == 'published':
|
||||||
anchor = ' while :; do\n inhibit_record='
|
anchor = ' while :; do\n inhibit_record='
|
||||||
edits = [(anchor, ' ' + pause + '\n' + anchor),
|
edits = [(anchor, ' ' + pause + '\n' + anchor),
|
||||||
(' exec -a "$expected"',
|
(' trap "kill \\$!; exit 0" TERM',
|
||||||
' while [[ ! -e $TEST_RELEASE_CHILD ]]; do /usr/bin/sleep 0.02; done\n exec -a "$expected"')]
|
' while [[ ! -e $TEST_RELEASE_CHILD ]]; do /usr/bin/sleep 0.02; done\n trap "kill \\$!; exit 0" TERM')]
|
||||||
elif sys.argv[2] == 'idle-temporary':
|
elif sys.argv[2] == 'idle-temporary':
|
||||||
anchor = ' temporary=$(mktemp "$state_dir/.${state_file##*/}.XXXXXXXX") || return 1'
|
anchor = ' temporary=$(mktemp "$state_dir/.${state_file##*/}.XXXXXXXX") || return 1'
|
||||||
edits = [(anchor, anchor + '\n if [[ $state_file == "$idle_owner_file" ]]; then ' + pause + '; fi')]
|
edits = [(anchor, anchor + '\n if [[ $state_file == "$idle_owner_file" ]]; then ' + pause + '; fi')]
|
||||||
|
|||||||
Reference in new issue
Block a user