Skip to content

Commit aca8e66

Browse files
committed
Implement raise
1 parent e6160a7 commit aca8e66

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/runtime.rs

+11
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,17 @@ pub unsafe fn tgkill(tid: Pid, sig: Signal) -> io::Result<()> {
450450
backend::runtime::syscalls::tgkill(tid, sig)
451451
}
452452

453+
/// `raise(sig)`—Send a signal to the current thread.
454+
///
455+
/// # References
456+
/// - [Linux]
457+
///
458+
/// [Linux]: https://man7.org/linux/man-pages/man3/raise.3.html
459+
#[inline]
460+
pub fn raise(sig: Signal) -> io::Result<()> {
461+
// SAFETY: This sends a signal to the current thread, and our own thread ID can't be recycled.
462+
unsafe { backend::runtime::syscalls::tkill(backend::thread::syscalls::gettid(), sig) }
463+
}
453464

454465
/// `rt_sigprocmask(how, set, oldset)`—Adjust the process signal mask.
455466
///

0 commit comments

Comments
 (0)