fix: party log --stop closes only the pipes it opened
Start already skipped panes the host had piped for other purposes, but --stop swept every pane, killing pipes party log never owned. Record the pane ids we pipe in .log-panes inside the per-party dir and close exactly those on --stop; the file dies with the dir.
This commit is contained in:
parent
fbe8317fee
commit
6c48777553
2 changed files with 24 additions and 6 deletions
20
party
20
party
|
|
@ -1092,6 +1092,7 @@ EOF
|
||||||
|
|
||||||
resolve_authoritative_party "$partyname" || exit 1
|
resolve_authoritative_party "$partyname" || exit 1
|
||||||
logfile="${RR_SOCKET%/sock}/log"
|
logfile="${RR_SOCKET%/sock}/log"
|
||||||
|
_lg_panesfile="${RR_SOCKET%/sock}/.log-panes"
|
||||||
|
|
||||||
if [ "$stop" = 1 ]; then
|
if [ "$stop" = 1 ]; then
|
||||||
# No log file means logging was never started this run; don't
|
# No log file means logging was never started this run; don't
|
||||||
|
|
@ -1101,12 +1102,16 @@ EOF
|
||||||
echo "party log: nothing was being logged."
|
echo "party log: nothing was being logged."
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
# pipe-pane with no command closes a pane's pipe; harmless on
|
# Close only the panes we recorded as ours; a pane the host
|
||||||
# panes that were never piped.
|
# piped for their own purposes was never listed here and must
|
||||||
"$PARTY_TMUX" -S "$RR_SOCKET" list-panes -s -t "$RR_PARTY_NAME" -F '#{pane_id}' \
|
# be left alone. `|| :` covers a recorded pane that's since
|
||||||
| while read -r _lg_p; do
|
# been killed, which would otherwise abort the loop under -e.
|
||||||
"$PARTY_TMUX" -S "$RR_SOCKET" pipe-pane -t "$_lg_p"
|
if [ -s "$_lg_panesfile" ]; then
|
||||||
done
|
while read -r _lg_p; do
|
||||||
|
"$PARTY_TMUX" -S "$RR_SOCKET" pipe-pane -t "$_lg_p" || :
|
||||||
|
done < "$_lg_panesfile"
|
||||||
|
rm -f "$_lg_panesfile"
|
||||||
|
fi
|
||||||
log_notify stopped
|
log_notify stopped
|
||||||
echo "Logging stopped. Transcript: $logfile"
|
echo "Logging stopped. Transcript: $logfile"
|
||||||
return 0
|
return 0
|
||||||
|
|
@ -1128,10 +1133,13 @@ EOF
|
||||||
# already-piped panes while still attaching new ones. The path is
|
# already-piped panes while still attaching new ones. The path is
|
||||||
# single-quoted for the server-side sh: a quote in PARTY_SOCKET_DIR
|
# single-quoted for the server-side sh: a quote in PARTY_SOCKET_DIR
|
||||||
# is accepted breakage, same as the status-right widget.
|
# is accepted breakage, same as the status-right widget.
|
||||||
|
# Record which panes we pipe so --stop closes only our own pipes,
|
||||||
|
# never one the host opened for their own purposes.
|
||||||
"$PARTY_TMUX" -S "$RR_SOCKET" list-panes -s -t "$RR_PARTY_NAME" -F '#{pane_pipe} #{pane_id}' \
|
"$PARTY_TMUX" -S "$RR_SOCKET" list-panes -s -t "$RR_PARTY_NAME" -F '#{pane_pipe} #{pane_id}' \
|
||||||
| while read -r _lg_piped _lg_p; do
|
| while read -r _lg_piped _lg_p; do
|
||||||
[ "$_lg_piped" = 1 ] && continue
|
[ "$_lg_piped" = 1 ] && continue
|
||||||
"$PARTY_TMUX" -S "$RR_SOCKET" pipe-pane -t "$_lg_p" "cat >> '$logfile'"
|
"$PARTY_TMUX" -S "$RR_SOCKET" pipe-pane -t "$_lg_p" "cat >> '$logfile'"
|
||||||
|
echo "$_lg_p" >> "$_lg_panesfile"
|
||||||
done
|
done
|
||||||
log_notify started
|
log_notify started
|
||||||
echo "Logging to $logfile"
|
echo "Logging to $logfile"
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,16 @@ poll_for() {
|
||||||
grep -q marker-KEEP "$saved"
|
grep -q marker-KEEP "$saved"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "log --stop leaves a manually piped pane alone" {
|
||||||
|
"$PARTY_BIN" host bystander
|
||||||
|
manual="$PARTY_TMP/manual-pipe.out"
|
||||||
|
tmux -S "$(sock_of bystander)" pipe-pane -t bystander "cat >> '$manual'"
|
||||||
|
"$PARTY_BIN" log
|
||||||
|
"$PARTY_BIN" log --stop
|
||||||
|
tmux -S "$(sock_of bystander)" send-keys -t bystander 'echo marker-MANUAL' Enter
|
||||||
|
poll_for "$manual" marker-MANUAL
|
||||||
|
}
|
||||||
|
|
||||||
@test "close without a transcript stays silent about rescue" {
|
@test "close without a transcript stays silent about rescue" {
|
||||||
export HOME="$PARTY_TMP/home"
|
export HOME="$PARTY_TMP/home"
|
||||||
mkdir -p "$HOME"
|
mkdir -p "$HOME"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue