1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 15:07:45 +00:00

Kernel: Stop using *LockRefPtr for ProcessGroup

Had to wrap Process::m_pg in a SpinlockProtected for this to be safe.
This commit is contained in:
Andreas Kling 2023-04-02 21:57:12 +02:00
parent ed1253ab90
commit 83b409083b
9 changed files with 31 additions and 23 deletions

View file

@ -96,7 +96,9 @@ ErrorOr<FlatPtr> Process::sys$fork(RegisterState& regs)
});
}));
child->m_pg = m_pg;
child->m_pg.with([&](auto& child_pg) {
child_pg = m_pg.with([&](auto& pg) { return pg; });
});
with_protected_data([&](auto& my_protected_data) {
child->with_mutable_protected_data([&](auto& child_protected_data) {

View file

@ -38,7 +38,8 @@ ErrorOr<FlatPtr> Process::sys$setsid()
return EPERM;
// Create a new Session and a new ProcessGroup.
m_pg = TRY(ProcessGroup::try_create(ProcessGroupID(pid().value())));
auto process_group = TRY(ProcessGroup::create(ProcessGroupID(pid().value())));
m_pg.with([&](auto& pg) { pg = move(process_group); });
m_tty = nullptr;
return with_mutable_protected_data([&](auto& protected_data) -> ErrorOr<FlatPtr> {
protected_data.sid = pid().value();
@ -119,7 +120,8 @@ ErrorOr<FlatPtr> Process::sys$setpgid(pid_t specified_pid, pid_t specified_pgid)
return EPERM;
}
// FIXME: There are more EPERM conditions to check for here..
process->m_pg = TRY(ProcessGroup::try_find_or_create(new_pgid));
auto process_group = TRY(ProcessGroup::find_or_create(new_pgid));
process->m_pg.with([&](auto& pg) { pg = move(process_group); });
return with_mutable_protected_data([&](auto& protected_data) -> ErrorOr<FlatPtr> {
auto credentials = this->credentials();

View file

@ -10,7 +10,7 @@
namespace Kernel {
ErrorOr<siginfo_t> Process::do_waitid(Variant<Empty, NonnullRefPtr<Process>, NonnullLockRefPtr<ProcessGroup>> waitee, int options)
ErrorOr<siginfo_t> Process::do_waitid(Variant<Empty, NonnullRefPtr<Process>, NonnullRefPtr<ProcessGroup>> waitee, int options)
{
ErrorOr<siginfo_t> result = siginfo_t {};
if (Thread::current()->block<Thread::WaitBlocker>({}, options, move(waitee), result).was_interrupted())
@ -25,7 +25,7 @@ ErrorOr<FlatPtr> Process::sys$waitid(Userspace<Syscall::SC_waitid_params const*>
TRY(require_promise(Pledge::proc));
auto params = TRY(copy_typed_from_user(user_params));
Variant<Empty, NonnullRefPtr<Process>, NonnullLockRefPtr<ProcessGroup>> waitee;
Variant<Empty, NonnullRefPtr<Process>, NonnullRefPtr<ProcessGroup>> waitee;
switch (params.idtype) {
case P_ALL:
break;