mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 09:27:35 +00:00
Kernel: Allow moving a process to a new pgrp via setpgid()
This commit is contained in:
parent
81b491a7a4
commit
29035b55b2
1 changed files with 6 additions and 1 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue