Use builder pattern to refactor the process module

This commit is contained in:
Jianfeng Jiang
2023-09-06 17:32:25 +08:00
committed by Tate, Hongliang Tian
parent 9ca64c281e
commit f540345bfd
42 changed files with 878 additions and 643 deletions

View File

@ -1,11 +1,7 @@
use crate::{
log_syscall_entry,
prelude::*,
process::{
process_group::ProcessGroup,
process_table::{self, pid_to_process},
Pgid, Pid,
},
process::{process_table, Pgid, Pid, ProcessGroup},
};
use super::{SyscallReturn, SYS_SETPGID};
@ -33,8 +29,8 @@ pub fn sys_setpgid(pid: Pid, pgid: Pgid) -> Result<SyscallReturn> {
return_errno_with_message!(Errno::EPERM, "process group must exist");
}
let process =
pid_to_process(pid).ok_or(Error::with_message(Errno::ESRCH, "process does not exist"))?;
let process = process_table::pid_to_process(pid)
.ok_or(Error::with_message(Errno::ESRCH, "process does not exist"))?;
// if the process already belongs to the process group
if process.pgid() == pgid {