mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 20:58:22 +00:00
initial signal implementation
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
#include <kernel/syscalls.h>
|
||||
#include <arch/cpu.h>
|
||||
#include <logging.h>
|
||||
|
||||
syscallret_t syscall_kill(context_t *context, int pid, int signal) {
|
||||
syscallret_t ret = {
|
||||
.ret = -1
|
||||
};
|
||||
|
||||
int effectivepid = -1;
|
||||
|
||||
if (pid > 0) // specific process
|
||||
effectivepid = pid;
|
||||
else if (pid == 0) // own process group
|
||||
effectivepid = 0;
|
||||
else if (pid == -1) // every process, unsupported atm
|
||||
effectivepid = -1;
|
||||
else if (pid < -1)
|
||||
effectivepid = -pid; // target specific process group
|
||||
|
||||
if (effectivepid == -1) {
|
||||
ret.errno = ESRCH;
|
||||
return ret;
|
||||
}
|
||||
|
||||
proc_t *target = sched_getprocfrompid(pid);
|
||||
if (target == NULL && pid != 0) {
|
||||
ret.errno = ESRCH;
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (pid >= 1)
|
||||
signal_signalproc(target, signal);
|
||||
else
|
||||
ret.errno = jobctl_signal(target, signal);
|
||||
|
||||
ret.errno = 0;
|
||||
ret.ret = 0;
|
||||
return ret;
|
||||
}
|
||||
Reference in New Issue
Block a user