From 2ba356050d3bfd7da749678fe191353080bd478a Mon Sep 17 00:00:00 2001 From: Yu Chen Date: Sat, 7 May 2022 11:37:29 +0800 Subject: [PATCH] add ctrl-c response in fs/stdio.rs::read. But the default sig action for SIGINT is still wrong --- os/src/fs/stdio.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/os/src/fs/stdio.rs b/os/src/fs/stdio.rs index 7c74d3e1..a45dff49 100644 --- a/os/src/fs/stdio.rs +++ b/os/src/fs/stdio.rs @@ -1,7 +1,7 @@ use super::File; use crate::mm::UserBuffer; use crate::sbi::console_getchar; -use crate::task::suspend_current_and_run_next; +use crate::task::{suspend_current_and_run_next,current_task,SignalFlags,}; pub struct Stdin; @@ -23,6 +23,12 @@ impl File for Stdin { if c == 0 { suspend_current_and_run_next(); continue; + } else if c == 3 { + // 3 is ctrl_c + let task = current_task().unwrap(); + let mut inner = task.inner_exclusive_access(); + inner.signals.insert(SignalFlags::SIGINT); + break; } else { break; }