Skip to content

Commit 1113c78

Browse files
authored
Set Ctrl-C signal handler (#123)
1 parent 2283331 commit 1113c78

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
lines changed

Cargo.lock

Lines changed: 32 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/shell/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ dirs = "5.0.1"
3434
which = "6.0.3"
3535
uu_uname = "0.0.27"
3636
uu_date = "0.0.27"
37+
ctrlc = "3.4.5"
3738

3839
[package.metadata.release]
3940
# Dont publish the binary

crates/shell/src/main.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ async fn interactive() -> anyhow::Result<()> {
3535
.completion_type(CompletionType::List)
3636
.build();
3737

38+
ctrlc::set_handler(move || {
39+
println!("Received Ctrl+C");
40+
})
41+
.expect("Error setting Ctrl-C handler");
42+
3843
let mut rl = Editor::with_config(config)?;
3944

4045
let helper = helper::ShellPromptHelper::default();

0 commit comments

Comments
 (0)