Skip to content

Commit

Permalink
Fix ctrl c in app crach the shell
Browse files Browse the repository at this point in the history
  • Loading branch information
Wyene committed Feb 27, 2024
1 parent 7b79203 commit 82f9456
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ serde = { version = "1.0.152", features = ["derive"] }
toml = "0.8.10"
termion = "3.0.0"
rustyline = {version= "13.0.0", features = ["derive"] }
libc = "0.2.153"
11 changes: 11 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
f
use libc::{sigaddset, sigemptyset, sigprocmask, SIGINT, SIG_BLOCK, SIG_UNBLOCK};
use std::collections::HashSet;

mod colors;
Expand Down Expand Up @@ -27,6 +29,15 @@ fn is_folder(path: &str) -> bool {
}

fn main() {
unsafe {
// Create an empty signal mask
let mut mask: libc::sigset_t = std::mem::zeroed();
sigemptyset(&mut mask);
// Add the SIGINT signal to the signal mask
sigaddset(&mut mask, SIGINT);
// Block the SIGINT signal using the signal mask
sigprocmask(SIG_BLOCK, &mask as *const libc::sigset_t, std::ptr::null_mut());
}
let line_config = rustyline::config::Config::builder()
.history_ignore_space(true)
.completion_type(rustyline::config::CompletionType::List)
Expand Down

0 comments on commit 82f9456

Please sign in to comment.