Fix sigsuspend and add it to the sigqueue test.
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -165,14 +165,14 @@ impl PalSignal for Sys {
|
||||
fn sigtimedwait(
|
||||
set: &sigset_t,
|
||||
sig: Option<&mut siginfo_t>,
|
||||
tp: ×pec,
|
||||
tp: Option<×pec>,
|
||||
) -> 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(|_| ())
|
||||
|
||||
@@ -42,6 +42,6 @@ pub trait PalSignal: Pal {
|
||||
fn sigtimedwait(
|
||||
set: &sigset_t,
|
||||
sig: Option<&mut siginfo_t>,
|
||||
tp: ×pec,
|
||||
tp: Option<×pec>,
|
||||
) -> Result<(), Errno>;
|
||||
}
|
||||
|
||||
@@ -274,14 +274,14 @@ impl PalSignal for Sys {
|
||||
fn sigtimedwait(
|
||||
set: &sigset_t,
|
||||
info_out: Option<&mut siginfo_t>,
|
||||
timeout: ×pec,
|
||||
timeout: Option<×pec>,
|
||||
) -> 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user