mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-11 20:48:49 +00:00
Allow ctrl-c to exit on crash
This commit is contained in:
parent
5c8b6adc2c
commit
d3ed3037c5
1 changed files with 10 additions and 1 deletions
11
src/panic.rs
11
src/panic.rs
|
@ -4,7 +4,7 @@ use std::{
|
|||
time::Duration,
|
||||
};
|
||||
|
||||
use libc::STDIN_FILENO;
|
||||
use libc::{SIGINT, SIG_DFL, STDIN_FILENO};
|
||||
use once_cell::sync::OnceCell;
|
||||
|
||||
use crate::{
|
||||
|
@ -45,6 +45,15 @@ pub fn panic_handler(main: impl FnOnce() -> i32 + UnwindSafe) -> ! {
|
|||
eprintf!(" Debug PID %d or press Enter to exit\n", unsafe {
|
||||
libc::getpid()
|
||||
});
|
||||
|
||||
{
|
||||
let mut act: libc::sigaction = unsafe { std::mem::zeroed() };
|
||||
act.sa_sigaction = SIG_DFL;
|
||||
unsafe { libc::sigemptyset(&mut act.sa_mask) };
|
||||
act.sa_flags = 0;
|
||||
unsafe { libc::sigaction(SIGINT, &act, std::ptr::null_mut()) };
|
||||
}
|
||||
|
||||
let mut buf = [0_u8; 1];
|
||||
while let Ok(n) = read_blocked(STDIN_FILENO, &mut buf) {
|
||||
if n == 0 || matches!(buf[0], b'q' | b'\n' | b'\r') {
|
||||
|
|
Loading…
Reference in a new issue