From 5aaaf9f8ce99e26811abab85dcb59f1dacef7bb2 Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Fri, 26 Oct 2018 23:15:08 +0900 Subject: [PATCH] kernel: setpgid fix --- kernel/sys/syscall.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/kernel/sys/syscall.c b/kernel/sys/syscall.c index e7b7a494..1e394914 100644 --- a/kernel/sys/syscall.c +++ b/kernel/sys/syscall.c @@ -939,21 +939,21 @@ static int sys_setpgid(pid_t pid, pid_t pgid) { return -EPERM; } - process_t * pgroup = process_from_pid(pgid); - - if (!pgroup) { - debug_print(WARNING, "bad session id"); - return -EPERM; - } - - if (pgroup->session != proc->session) { - debug_print(WARNING, "tried to move to different session"); - return -EPERM; - } - if (pgid == 0) { proc->job = proc->group; } else { + process_t * pgroup = process_from_pid(pgid); + + if (!pgroup) { + debug_print(WARNING, "bad session id"); + return -EPERM; + } + + if (pgroup->session != proc->session) { + debug_print(WARNING, "tried to move to different session"); + return -EPERM; + } + proc->job = pgid; } return 0;