fix: a signal during party host rolls back and stops
The rollback trap was armed on EXIT INT TERM HUP with a body that did not exit. After a signal the shell ran the cleanup, then resumed cmd_host and kept configuring the party dir it had just removed. Keep the cleanup on EXIT and make the signal traps exit with the conventional 128+n status.
This commit is contained in:
parent
6c48777553
commit
851cef6941
2 changed files with 26 additions and 1 deletions
|
|
@ -39,6 +39,9 @@ case "$*" in
|
|||
*"new-session -d "*)
|
||||
# cmd_host expects the socket file to exist for apply_party_perms_file.
|
||||
[ -n "$sock" ] && : > "$sock"
|
||||
# Optional injection point for the signal test: TERM the calling
|
||||
# party process while it waits on us, mid-setup.
|
||||
[ -n "${SIGNAL_ON_NEWSESSION:-}" ] && kill -TERM "$PPID"
|
||||
;;
|
||||
*"display-message -p "*)
|
||||
# Caller is fishing for #{pid}; emit the sleeper's PID.
|
||||
|
|
@ -557,6 +560,21 @@ STUB
|
|||
[ ! -e "$party_dir" ]
|
||||
}
|
||||
|
||||
@test "host interrupted by a signal rolls back and stops" {
|
||||
# A signal trap body that does not exit lets the shell resume where
|
||||
# it left off: cmd_host would clean up, then carry on configuring a
|
||||
# party dir it just removed. The signal must end the run.
|
||||
party_dir="$PARTY_SOCKET_DIR/party-$USER:sigterm.d"
|
||||
|
||||
SIGNAL_ON_NEWSESSION=1 run "$PARTY_BIN" host sigterm
|
||||
[ "$status" -eq 143 ]
|
||||
|
||||
[ ! -e "$party_dir" ]
|
||||
# Nothing but the rollback's kill-server follows new-session.
|
||||
[ "$(sed -n '/new-session -d /,$p' "$TMUX_LOG" | sed 1d)" \
|
||||
= "-S $party_dir/sock kill-server" ]
|
||||
}
|
||||
|
||||
@test "host refuses leftover per-party dir without a roster" {
|
||||
# Simulate a prior incarnation that left a per-party dir behind with
|
||||
# no roster (the rollback trap couldn't fire — SIGKILL or panic).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue