mirror of
https://github.com/rcore-os/rCore-Tutorial-v3.git
synced 2024-11-26 03:13:36 +04:00
Remove Ctrl-C in stdio && remove sig_ctrlc(will be back in ch9)
This commit is contained in:
parent
a0e2bf4c58
commit
e8bb2e3afa
@ -23,12 +23,12 @@ impl File for Stdin {
|
||||
if c == 0 {
|
||||
suspend_current_and_run_next();
|
||||
continue;
|
||||
} else if c == 3 {
|
||||
}/* else if c == 3 {
|
||||
// 3 is ctrl_c
|
||||
//println!("[K] os/fs/stdio/read: Got Ctrl_C");
|
||||
current_add_signal(SignalFlags::SIGINT);
|
||||
break;
|
||||
} else {
|
||||
}*/ else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1,39 +0,0 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
extern crate user_lib;
|
||||
use user_lib::console::getchar;
|
||||
use user_lib::*;
|
||||
|
||||
const LF: u8 = 0x0au8;
|
||||
const CR: u8 = 0x0du8;
|
||||
|
||||
fn func() {
|
||||
println!("signal_handler: caught signal SIGINT, and exit(1)");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub fn main() -> i32 {
|
||||
println!("sig_ctrlc starting.... Press 'ctrl-c' or 'ENTER' will quit.");
|
||||
|
||||
let mut new = SignalAction::default();
|
||||
let old = SignalAction::default();
|
||||
new.handler = func as usize;
|
||||
|
||||
println!("sig_ctrlc: sigaction");
|
||||
if sigaction(SIGINT, &new, &old) < 0 {
|
||||
panic!("Sigaction failed!");
|
||||
}
|
||||
println!("sig_ctrlc: getchar....");
|
||||
loop {
|
||||
let c = getchar();
|
||||
|
||||
println!("Got Char {}", c);
|
||||
if c == LF || c == CR {
|
||||
break;
|
||||
}
|
||||
}
|
||||
println!("sig_ctrlc: Done");
|
||||
0
|
||||
}
|
Loading…
Reference in New Issue
Block a user