mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-08 14:16:47 +00:00
修复tty处理信号时错误地将前台进程组置空的问题 & clone时未拷贝父进程tty的问题 (#1043)
* 修复clone时未拷贝父进程tty的问题 * 修复tty处理信号时错误地将前台进程组置空的问题
This commit is contained in:
parent
0f094e50de
commit
ff76b0fcb8
@ -785,14 +785,12 @@ impl NTtyData {
|
||||
signal: Signal,
|
||||
) {
|
||||
// 先处理信号
|
||||
let mut ctrl_info = tty.core().contorl_info_irqsave();
|
||||
let ctrl_info = tty.core().contorl_info_irqsave();
|
||||
let pg = ctrl_info.pgid;
|
||||
if let Some(pg) = pg {
|
||||
let _ = Syscall::kill(pg, signal as i32);
|
||||
}
|
||||
|
||||
ctrl_info.pgid = None;
|
||||
|
||||
if !termios.local_mode.contains(LocalMode::NOFLSH) {
|
||||
// 重置
|
||||
self.echo_head = 0;
|
||||
|
@ -169,11 +169,6 @@ impl ProcessManager {
|
||||
|
||||
let pcb = ProcessControlBlock::new(name, new_kstack);
|
||||
|
||||
// TODO: 注意!这里设置tty的操作不符合Linux的行为!(毕竟创建进程不一定要fork,也可以用clone来创建)
|
||||
// 正确做法应该是在实现进程组之后去管理前台进程组。
|
||||
pcb.sig_info_mut()
|
||||
.set_tty(current_pcb.sig_info_irqsave().tty());
|
||||
|
||||
let mut args = KernelCloneArgs::new();
|
||||
args.flags = clone_flags;
|
||||
args.exit_signal = Signal::SIGCHLD;
|
||||
|
@ -705,16 +705,17 @@ impl ProcessControlBlock {
|
||||
|
||||
#[inline(never)]
|
||||
fn do_create_pcb(name: String, kstack: KernelStack, is_idle: bool) -> Arc<Self> {
|
||||
let (pid, ppid, cwd, cred) = if is_idle {
|
||||
let (pid, ppid, cwd, cred, tty) = if is_idle {
|
||||
let cred = INIT_CRED.clone();
|
||||
(Pid(0), Pid(0), "/".to_string(), cred)
|
||||
(Pid(0), Pid(0), "/".to_string(), cred, None)
|
||||
} else {
|
||||
let ppid = ProcessManager::current_pcb().pid();
|
||||
let mut cred = ProcessManager::current_pcb().cred();
|
||||
cred.cap_permitted = cred.cap_ambient;
|
||||
cred.cap_effective = cred.cap_ambient;
|
||||
let cwd = ProcessManager::current_pcb().basic().cwd();
|
||||
(Self::generate_pid(), ppid, cwd, cred)
|
||||
let tty = ProcessManager::current_pcb().sig_info_irqsave().tty();
|
||||
(Self::generate_pid(), ppid, cwd, cred, tty)
|
||||
};
|
||||
|
||||
let basic_info = ProcessBasicInfo::new(Pid(0), ppid, Pid(0), name, cwd, None);
|
||||
@ -754,6 +755,8 @@ impl ProcessControlBlock {
|
||||
cred: SpinLock::new(cred),
|
||||
};
|
||||
|
||||
pcb.sig_info.write().set_tty(tty);
|
||||
|
||||
// 初始化系统调用栈
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
pcb.arch_info
|
||||
|
Loading…
x
Reference in New Issue
Block a user