mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:17:45 +00:00
Kernel: Remove ProcessInspectionHandle and make Process RefCounted
By making the Process class RefCounted we don't really need ProcessInspectionHandle anymore. This also fixes some race conditions where a Process may be deleted while still being used by ProcFS. Also make sure to acquire the Process' lock when accessing regions. Last but not least, there's no reason why a thread can't be scheduled while being inspected, though in practice it won't happen anyway because the scheduler lock is held at the same time.
This commit is contained in:
parent
5bbf6ed46b
commit
538b985487
13 changed files with 191 additions and 273 deletions
|
@ -35,7 +35,7 @@ pid_t Process::sys$getsid(pid_t pid)
|
|||
if (pid == 0)
|
||||
return m_sid;
|
||||
ScopedSpinLock lock(g_processes_lock);
|
||||
auto* process = Process::from_pid(pid);
|
||||
auto process = Process::from_pid(pid);
|
||||
if (!process)
|
||||
return -ESRCH;
|
||||
if (m_sid != process->m_sid)
|
||||
|
@ -66,7 +66,7 @@ pid_t Process::sys$getpgid(pid_t pid)
|
|||
if (pid == 0)
|
||||
return m_pgid;
|
||||
ScopedSpinLock lock(g_processes_lock); // FIXME: Use a ProcessHandle
|
||||
auto* process = Process::from_pid(pid);
|
||||
auto process = Process::from_pid(pid);
|
||||
if (!process)
|
||||
return -ESRCH;
|
||||
return process->m_pgid;
|
||||
|
@ -81,7 +81,7 @@ pid_t Process::sys$getpgrp()
|
|||
static pid_t get_sid_from_pgid(pid_t pgid)
|
||||
{
|
||||
ScopedSpinLock lock(g_processes_lock);
|
||||
auto* group_leader = Process::from_pid(pgid);
|
||||
auto group_leader = Process::from_pid(pgid);
|
||||
if (!group_leader)
|
||||
return -1;
|
||||
return group_leader->sid();
|
||||
|
@ -96,7 +96,7 @@ int Process::sys$setpgid(pid_t specified_pid, pid_t specified_pgid)
|
|||
// The value of the pgid argument is less than 0, or is not a value supported by the implementation.
|
||||
return -EINVAL;
|
||||
}
|
||||
auto* process = Process::from_pid(pid);
|
||||
auto process = Process::from_pid(pid);
|
||||
if (!process)
|
||||
return -ESRCH;
|
||||
if (process != this && process->ppid() != m_pid) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue