Fix two instances of double RefCell borrow.

This commit is contained in:
4lDO2
2025-03-31 14:43:35 +02:00
parent bdf9563688
commit ae05abf69d
+13 -11
View File
@@ -841,6 +841,16 @@ impl<'a> ProcScheme<'a> {
Ok(target_proc.pgid)
}
pub fn on_setsid(&mut self, caller_pid: ProcessId) -> Result<()> {
// TODO: more efficient?
// POSIX: any other process's pgid matches the caller pid
if self
.processes
.values()
.any(|p| p.borrow().pgid == caller_pid)
{
return Err(Error::new(EPERM));
}
let mut caller_proc = self
.processes
.get(&caller_pid)
@@ -851,15 +861,6 @@ impl<'a> ProcScheme<'a> {
if caller_proc.pgid == caller_pid {
return Err(Error::new(EPERM));
}
// TODO: more efficient?
// POSIX: any other process's pgid matches the caller pid
if self
.processes
.values()
.any(|p| p.borrow().pgid == caller_pid)
{
return Err(Error::new(EPERM));
}
caller_proc.pgid = caller_pid;
caller_proc.sid = caller_pid;
@@ -1059,8 +1060,9 @@ impl<'a> ProcScheme<'a> {
let this_pgid = proc.pgid;
if !self
.processes
.values()
.any(|p| p.borrow().pgid == this_pgid)
.iter()
.filter(|(pid, _)| **pid != this_pid)
.any(|(_, p)| p.borrow().pgid == this_pgid)
{
return Ready(Err(Error::new(ECHILD)));
}