Use ParentProcess to cache parent pid

This commit is contained in:
Qingsong Chen
2024-09-12 08:40:32 +00:00
committed by Tate, Hongliang Tian
parent f01772ca85
commit 787604b7f6
3 changed files with 68 additions and 12 deletions

View File

@ -4,9 +4,5 @@ use super::SyscallReturn;
use crate::prelude::*;
pub fn sys_getppid(ctx: &Context) -> Result<SyscallReturn> {
let parent = ctx.process.parent();
match parent {
None => Ok(SyscallReturn::Return(0)),
Some(parent) => Ok(SyscallReturn::Return(parent.pid() as _)),
}
Ok(SyscallReturn::Return(ctx.process.parent().pid() as _))
}