mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-22 02:53:23 +00:00
fix: 检测不到ctrl+D的问题 && pid=1被kill的时候没报错的问题 (#1206)
Signed-off-by: longjin <longjin@DragonOS.org>
This commit is contained in:
@ -284,6 +284,8 @@ pub trait BitMapOps<T: BitOps> {
|
||||
fn last_false_index(&self) -> Option<usize>;
|
||||
|
||||
/// 获取指定index之后第一个为1的位的index
|
||||
///
|
||||
/// **注意**: 这个不包含当前的index位(如果index位的值是1,那么它是会跳过这个位的)
|
||||
fn next_index(&self, index: usize) -> Option<usize>;
|
||||
|
||||
/// 获取指定index之后第一个为0的位的index
|
||||
|
@ -1018,7 +1018,13 @@ impl NTtyData {
|
||||
};
|
||||
|
||||
// 找到eol的坐标
|
||||
let tmp = self.read_flags.next_index(tail);
|
||||
// 注意:next_index可能不包括起始位置,所以我们需要手动检查tail位置
|
||||
|
||||
let tmp: Option<usize> = if self.read_flags.get(tail).unwrap_or(false) {
|
||||
Some(tail)
|
||||
} else {
|
||||
self.read_flags.next_index(tail)
|
||||
};
|
||||
// 找到的话即为坐标,未找到的话即为NTTY_BUFSIZE
|
||||
let mut eol = if let Some(tmp) = tmp { tmp } else { size };
|
||||
if eol > size {
|
||||
|
@ -412,6 +412,19 @@ impl ProcessManager {
|
||||
///
|
||||
/// 因此注意,传入的`exit_code`应该是已经完成了移位操作的
|
||||
pub fn exit(exit_code: usize) -> ! {
|
||||
// 检查是否是init进程尝试退出,如果是则产生panic
|
||||
let current_pcb = ProcessManager::current_pcb();
|
||||
if current_pcb.pid() == Pid(1) {
|
||||
log::error!(
|
||||
"Init process (pid=1) attempted to exit with code {}. This should not happen and indicates a serious system error.",
|
||||
exit_code
|
||||
);
|
||||
loop {
|
||||
spin_loop();
|
||||
}
|
||||
}
|
||||
drop(current_pcb);
|
||||
|
||||
// 关中断
|
||||
let _irq_guard = unsafe { CurrentIrqArch::save_and_disable_irq() };
|
||||
let pid: Pid;
|
||||
|
Reference in New Issue
Block a user