mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
Don't break out of panic handler
The previous control flow logic wasn't sound and would leave the shell in a hung state when `break` would be encountered. The behavior is now straightforward, the shell reads until <Enter> or <q> is pressed, at which point it aborts.
This commit is contained in:
parent
4d0aa2b5dd
commit
5278259312
1 changed files with 3 additions and 5 deletions
|
@ -18,13 +18,11 @@ pub fn panic_handler(main: impl FnOnce() -> i32 + UnwindSafe) -> ! {
|
||||||
PROGRAM_NAME.get().unwrap(),
|
PROGRAM_NAME.get().unwrap(),
|
||||||
unsafe { libc::getpid() }
|
unsafe { libc::getpid() }
|
||||||
);
|
);
|
||||||
|
// Move the cursor down so it isn't blocking the text
|
||||||
|
eprintf!("\n");
|
||||||
let mut buf = [0_u8; 1];
|
let mut buf = [0_u8; 1];
|
||||||
loop {
|
loop {
|
||||||
// Move the cursor down so it isn't blocking the text
|
let n = read_blocked(STDIN_FILENO, &mut buf).unwrap_or(0);
|
||||||
eprintf!("\n");
|
|
||||||
let Ok(n) = read_blocked(STDIN_FILENO, &mut buf) else {
|
|
||||||
break;
|
|
||||||
};
|
|
||||||
if n == 0 || matches!(buf[0], b'q' | b'\n' | b'\r') {
|
if n == 0 || matches!(buf[0], b'q' | b'\n' | b'\r') {
|
||||||
eprintf!("\n");
|
eprintf!("\n");
|
||||||
std::process::abort();
|
std::process::abort();
|
||||||
|
|
Loading…
Reference in a new issue