wasmer_wasix/syscalls/wasi/
proc_raise.rs

1use super::*;
2use crate::syscalls::*;
3
4/// ### `proc_raise()`
5/// Send a signal to the process of the calling thread.
6/// Note: This is similar to `raise` in POSIX.
7/// Inputs:
8/// - `Signal`
9///   Signal to be raised for this process
10#[instrument(level = "trace", skip_all, fields(sig), ret)]
11pub fn proc_raise(mut ctx: FunctionEnvMut<'_, WasiEnv>, sig: Signal) -> Result<Errno, WasiError> {
12    let env = ctx.data();
13    env.process.signal_process(sig);
14
15    WasiEnv::do_pending_operations(&mut ctx)?;
16
17    Ok(Errno::Success)
18}
19
20/// ### `proc_raise()`
21/// Send a signal to the process of the calling thread.
22/// Note: This is similar to `raise` in POSIX.
23/// Inputs:
24/// - `Signal`
25///   Signal to be raised for this process
26pub fn proc_raise_interval(
27    mut ctx: FunctionEnvMut<'_, WasiEnv>,
28    sig: Signal,
29    interval: Timestamp,
30    repeat: Bool,
31) -> Result<Errno, WasiError> {
32    let env = ctx.data();
33    let interval = match interval {
34        0 => None,
35        a => Some(Duration::from_millis(a)),
36    };
37    let repeat = matches!(repeat, Bool::True);
38    env.process.signal_interval(sig, interval, repeat);
39
40    WasiEnv::do_pending_operations(&mut ctx)?;
41
42    Ok(Errno::Success)
43}