mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-30 11:21:15 -03:00
Fix bracketed paste potentially not being disabled on SIGTERM
When we enable/disable terminal protocols, we use atomic operations because of issues like 1. halfway through enabling, we might be interrupted by a signal handler. 2. our SIGTERM handler runs the (idempotent) disabling sequences, so the operations must be async-signal safe. The flags to keep track of whether things like kitty keyboard protocol are enabled are "mirrored" between the enabling and disabling logic: - the enabling logic marks it as enabled *before* enabling anything - the disabling logic marks it as disabled *after* everything has been disabled This ensures that we are well-behaved in issue 1; we will always (perhaps redundantly) disable the kitty keyboard protocol. We forgot to use the same ordering for bracketed paste. If we get SIGTERM after this line BRACKETED_PASTE.store(false, Ordering::Release); we might exit with bracketed paste still turned on.
This commit is contained in:
@@ -552,11 +552,11 @@ pub(crate) fn terminal_protocols_disable_ifn() {
|
||||
})
|
||||
});
|
||||
if BRACKETED_PASTE.load(Ordering::Acquire) {
|
||||
BRACKETED_PASTE.store(false, Ordering::Release);
|
||||
let _ = write_loop(&STDOUT_FILENO, b"\x1b[?2004l");
|
||||
if IS_TMUX.load() {
|
||||
let _ = write_loop(&STDOUT_FILENO, "\x1b[?1004l".as_bytes());
|
||||
}
|
||||
BRACKETED_PASTE.store(false, Ordering::Release);
|
||||
did_write.store(true);
|
||||
}
|
||||
if !TERMINAL_PROTOCOLS.load(Ordering::Acquire) {
|
||||
|
||||
Reference in New Issue
Block a user