1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:47:46 +00:00

Kernel: Allow moving a process to a new pgrp via setpgid()

This commit is contained in:
AnotherTest 2020-08-11 15:53:02 +04:30 committed by Andreas Kling
parent 81b491a7a4
commit 29035b55b2

View file

@ -124,10 +124,15 @@ int Process::sys$setpgid(pid_t specified_pid, pid_t specified_pgid)
ProcessGroupID new_pgid = specified_pgid ? ProcessGroupID(specified_pgid) : process->m_pid.value();
SessionID current_sid = sid();
SessionID new_sid = get_sid_from_pgid(new_pgid);
if (current_sid != new_sid) {
if (new_sid != -1 && current_sid != new_sid) {
// Can't move a process between sessions.
return -EPERM;
}
if (new_sid == -1 && new_pgid != process->m_pid.value()) {
// The value of the pgid argument is valid, but is not
// the calling pid, and is not an existing process group.
return -EPERM;
}
// FIXME: There are more EPERM conditions to check for here..
process->m_pgid = new_pgid;
return 0;