Fix sigsuspend and add it to the sigqueue test.

This commit is contained in:
4lDO2
2024-08-04 23:02:04 +02:00
parent 9701e9c544
commit 2b7a1ea94b
6 changed files with 69 additions and 24 deletions
+9 -2
View File
@@ -380,13 +380,20 @@ pub unsafe extern "C" fn sigwait(set: *const sigset_t, sig: *mut c_int) -> c_int
#[no_mangle]
pub unsafe extern "C" fn sigtimedwait(
set: *const sigset_t,
sig: *mut siginfo, // https://github.com/mozilla/cbindgen/issues/621
// s/siginfo_t/siginfo due to https://github.com/mozilla/cbindgen/issues/621
sig: *mut siginfo,
// POSIX leaves behavior unspecified if this is NULL, but on both Linux and Redox, NULL is used
// to differentiate between sigtimedwait and sigwaitinfo internally
tp: *const timespec,
) -> c_int {
Sys::sigtimedwait(&*set, sig.as_mut(), &*tp)
Sys::sigtimedwait(&*set, sig.as_mut(), tp.as_ref())
.map(|()| 0)
.or_minus_one_errno()
}
#[no_mangle]
pub unsafe extern "C" fn sigwaitinfo(set: *const sigset_t, sig: *mut siginfo_t) -> c_int {
sigtimedwait(set, sig, core::ptr::null())
}
pub const _signal_strings: [&str; 32] = [
"Unknown signal\0",
+3 -3
View File
@@ -165,14 +165,14 @@ impl PalSignal for Sys {
fn sigtimedwait(
set: &sigset_t,
sig: Option<&mut siginfo_t>,
tp: &timespec,
tp: Option<&timespec>,
) -> Result<(), Errno> {
unsafe {
e_raw(syscall!(
RT_SIGTIMEDWAIT,
set as *const _,
sig.map_or_else(core::ptr::null_mut, |s| s as *mut _) as usize,
tp as *const _,
sig.map_or_else(core::ptr::null_mut, |s| s as *mut _),
tp.map_or_else(core::ptr::null, |t| t as *const _),
NSIG / 8
))
.map(|_| ())
+1 -1
View File
@@ -42,6 +42,6 @@ pub trait PalSignal: Pal {
fn sigtimedwait(
set: &sigset_t,
sig: Option<&mut siginfo_t>,
tp: &timespec,
tp: Option<&timespec>,
) -> Result<(), Errno>;
}
+4 -4
View File
@@ -274,14 +274,14 @@ impl PalSignal for Sys {
fn sigtimedwait(
set: &sigset_t,
info_out: Option<&mut siginfo_t>,
timeout: &timespec,
timeout: Option<&timespec>,
) -> Result<(), Errno> {
// TODO: deadline-based API
let timeout = syscall::TimeSpec {
let timeout = timeout.map(|timeout| syscall::TimeSpec {
tv_sec: timeout.tv_sec,
tv_nsec: timeout.tv_nsec as _,
};
let info = redox_rt::signal::await_signal_sync(*set, &timeout)?.into();
});
let info = redox_rt::signal::await_signal_sync(*set, timeout.as_ref())?.into();
if let Some(out) = info_out {
*out = info;
}