Skip to content

Commit c9464f2

Browse files
committed
ctrl c working?
1 parent ecfca91 commit c9464f2

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/main.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ pub extern "C" fn sigchld_handler(_signum: i32) {
1717
*jobs = true;
1818
}
1919

20+
pub extern "C" fn sigint_handler(_signum: i32) {
21+
// Handle SIGINT (Ctrl+C) do nothing
22+
}
23+
2024
fn repl() {
2125
let stdin = io::stdin();
2226
let mut stdout = io::stdout();
@@ -34,6 +38,12 @@ fn repl() {
3438
signal::SigHandler::Handler(sigchld_handler),
3539
)
3640
.expect("Error setting signal handler");
41+
42+
signal::signal(
43+
signal::Signal::SIGINT,
44+
signal::SigHandler::Handler(sigint_handler),
45+
)
46+
.expect("Error setting signal handler for SIGINT");
3747
}
3848
if let Some(arg) = env::args().nth(1) {
3949
let code_str = std::fs::read_to_string(arg).expect("Error reading file");

0 commit comments

Comments
 (0)