Skip to content

Commit

Permalink
Kernel: Allow moving a process to a new pgrp via setpgid()
Browse files Browse the repository at this point in the history
  • Loading branch information
alimpfard authored and awesomekling committed Aug 12, 2020
1 parent 81b491a commit 29035b5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Kernel/Syscalls/setpgid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 29035b5

Please sign in to comment.