fix: 修复SignalStruct创建的时候,栈上内存占用过大的问题 (#1201)

Signed-off-by: longjin <longjin@DragonOS.org>
This commit is contained in:
LoGin 2025-06-12 01:32:14 +08:00 committed by GitHub
parent e696ba4440
commit 478d68a4de
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View File

@ -5,7 +5,7 @@ use core::{
sync::atomic::AtomicI64,
};
use alloc::{boxed::Box, vec::Vec};
use alloc::vec::Vec;
use system_error::SystemError;
use crate::{
@ -60,7 +60,7 @@ pub const SIG_KERNEL_IGNORE_MASK: SigSet = Signal::into_sigset(Signal::SIGCONT)
/// SignalStruct 在 pcb 中加锁
#[derive(Debug)]
pub struct SignalStruct {
inner: Box<InnerSignalStruct>,
inner: InnerSignalStruct,
}
#[derive(Debug)]
@ -69,14 +69,14 @@ pub struct InnerSignalStruct {
pub cnt: AtomicI64,
/// 如果对应linux这部分会有一个引用计数但是没发现在哪里有用到需要计算引用的地方因此
/// 暂时删掉不然这个Arc会导致其他地方的代码十分丑陋
pub handlers: [Sigaction; MAX_SIG_NUM],
pub handlers: Vec<Sigaction>,
}
impl SignalStruct {
#[inline(never)]
pub fn new() -> Self {
let mut r = Self {
inner: Box::<InnerSignalStruct>::default(),
inner: InnerSignalStruct::default(),
};
let mut sig_ign = Sigaction::default();
// 收到忽略的信号,重启系统调用
@ -115,7 +115,7 @@ impl Default for InnerSignalStruct {
fn default() -> Self {
Self {
cnt: Default::default(),
handlers: [Sigaction::default(); MAX_SIG_NUM],
handlers: vec![Sigaction::default(); MAX_SIG_NUM],
}
}
}

View File

@ -321,7 +321,7 @@ impl ProcessManager {
}
// log::debug!("Just copy sighand");
new_pcb.sig_struct_irqsave().handlers = current_pcb.sig_struct_irqsave().handlers;
new_pcb.sig_struct_irqsave().handlers = current_pcb.sig_struct_irqsave().handlers.clone();
if clone_flags.contains(CloneFlags::CLONE_CLEAR_SIGHAND) {
flush_signal_handlers(new_pcb.clone(), false);