diff options
author | Ian Moffett <ian@osmora.org> | 2025-03-27 00:12:03 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-03-27 00:12:03 -0400 |
commit | b45c038a7899e2f396b0d248c22db037d58f3158 (patch) | |
tree | c887ca25bf9052b09d71db8266d70ef9002d36bc /sys/include | |
parent | 3d99d2fbd600091a3dec0697e35dddfca17621ab (diff) |
kernel: systm: Add __sigraise() helper
Adds routine to raise a signal on the fly for the current calling thread.
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/include')
-rw-r--r-- | sys/include/sys/systm.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/sys/include/sys/systm.h b/sys/include/sys/systm.h index 38327f6..89f196f 100644 --- a/sys/include/sys/systm.h +++ b/sys/include/sys/systm.h @@ -31,10 +31,28 @@ #define _SYS_SYSTM_H_ #include <sys/types.h> +#include <sys/signal.h> +#include <sys/proc.h> #if defined(_KERNEL) int copyin(const void *uaddr, void *kaddr, size_t len); int copyout(const void *kaddr, void *uaddr, size_t len); int copyinstr(const void *uaddr, char *kaddr, size_t len); + +__always_inline static inline void +__sigraise(int signo) +{ + struct proc *td; + sigset_t sigs; + + td = this_td(); + __assert(td != NULL && "pid 1 not running"); + sigemptyset(&sigs); + + sigaddset(&sigs, signo); + sendsig(td, &sigs); + dispatch_signals(td); +} + #endif /* _KERNEL */ #endif /* !_SYS_SYSTM_H_ */ |