mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-01 23:18:21 +00:00
setpgid: check if pid is the current proc or a child
This commit is contained in:
@@ -13,9 +13,16 @@ syscallret_t syscall_setsid(context_t *) {
|
|||||||
syscallret_t syscall_setpgid(context_t *, pid_t pid, pid_t pgid) {
|
syscallret_t syscall_setpgid(context_t *, pid_t pid, pid_t pgid) {
|
||||||
syscallret_t ret;
|
syscallret_t ret;
|
||||||
|
|
||||||
|
proc_t *currentproc = _cpu()->thread->proc;
|
||||||
|
|
||||||
|
if (pgid < 0) {
|
||||||
|
ret.errno = EINVAL;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
proc_t *proc = NULL;
|
proc_t *proc = NULL;
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
proc = _cpu()->thread->proc;
|
proc = currentproc;
|
||||||
PROC_HOLD(proc);
|
PROC_HOLD(proc);
|
||||||
} else {
|
} else {
|
||||||
proc = sched_getprocfrompid(pid);
|
proc = sched_getprocfrompid(pid);
|
||||||
@@ -26,9 +33,15 @@ syscallret_t syscall_setpgid(context_t *, pid_t pid, pid_t pgid) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (proc != currentproc && proc->parent != currentproc) {
|
||||||
|
ret.errno = ESRCH;
|
||||||
|
PROC_RELEASE(proc);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
proc_t *pgrp = NULL;
|
proc_t *pgrp = NULL;
|
||||||
if (pgid == 0) {
|
if (pgid == 0) {
|
||||||
pgrp = _cpu()->thread->proc;
|
pgrp = currentproc;
|
||||||
PROC_HOLD(pgrp);
|
PROC_HOLD(pgrp);
|
||||||
} else {
|
} else {
|
||||||
pgrp = sched_getprocfrompid(pgid);
|
pgrp = sched_getprocfrompid(pgid);
|
||||||
|
|||||||
Reference in New Issue
Block a user