From aca8e66854658fc513b49f3f7464f3cea1d7fc1f Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Sat, 4 Jan 2025 18:04:45 +0200 Subject: [PATCH] Implement `raise` --- src/runtime.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/runtime.rs b/src/runtime.rs index 0b2fc0649..382e940df 100644 --- a/src/runtime.rs +++ b/src/runtime.rs @@ -450,6 +450,17 @@ pub unsafe fn tgkill(tid: Pid, sig: Signal) -> io::Result<()> { backend::runtime::syscalls::tgkill(tid, sig) } +/// `raise(sig)`—Send a signal to the current thread. +/// +/// # References +/// - [Linux] +/// +/// [Linux]: https://man7.org/linux/man-pages/man3/raise.3.html +#[inline] +pub fn raise(sig: Signal) -> io::Result<()> { + // SAFETY: This sends a signal to the current thread, and our own thread ID can't be recycled. + unsafe { backend::runtime::syscalls::tkill(backend::thread::syscalls::gettid(), sig) } +} /// `rt_sigprocmask(how, set, oldset)`—Adjust the process signal mask. ///