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:
Mahmoud Al-Qudsi 2024-08-28 17:35:29 -05:00
parent 4d0aa2b5dd
commit 5278259312

View file

@ -18,13 +18,11 @@ pub fn panic_handler(main: impl FnOnce() -> i32 + UnwindSafe) -> ! {
PROGRAM_NAME.get().unwrap(),
unsafe { libc::getpid() }
);
let mut buf = [0_u8; 1];
loop {
// Move the cursor down so it isn't blocking the text
eprintf!("\n");
let Ok(n) = read_blocked(STDIN_FILENO, &mut buf) else {
break;
};
let mut buf = [0_u8; 1];
loop {
let n = read_blocked(STDIN_FILENO, &mut buf).unwrap_or(0);
if n == 0 || matches!(buf[0], b'q' | b'\n' | b'\r') {
eprintf!("\n");
std::process::abort();