#include #include "syscall.h" #include "proc/proc.h" #include "spinlock/spinlock.h" #include "hdrs/errors.h" #include "util/util.h" #define PID_SELF_MAGIC 0x5E1F enum { PCTL_KILL = 0, }; typedef struct { } ProcessCtl; int32_t SYSCALL3(sys_processctl, pid1, cmd1, optsptr1) { uint64_t pid = pid1; uint64_t cmd = cmd1; ProcessCtl *pctl = (ProcessCtl *)(void *)optsptr1; int32_t ret = E_OK; spinlock_acquire(&PROCS.spinlock); if (pid == PID_SELF_MAGIC) { pid = PROCS.current->pid; } Proc *proc = NULL; LL_FINDPROP(PROCS.procs, proc, pid, pid); if (proc == NULL) { ret = E_INVALIDARGUMENT; goto done; } switch (cmd) { case PCTL_KILL: { proc_kill(proc); ret = E_DOSCHEDULING; goto done; } break; default: { ret = E_INVALIDARGUMENT; goto done; } break; } done: spinlock_release(&PROCS.spinlock); return ret; }