Implement sigsuspend.

This commit is contained in:
4lDO2
2024-08-04 18:31:24 +02:00
parent 33f0df3b27
commit 8e5ddbd654
5 changed files with 34 additions and 22 deletions
+4 -2
View File
@@ -155,8 +155,10 @@ impl PalSignal for Sys {
.map(|_| ())
}
fn sigsuspend(set: &sigset_t) -> c_int {
unsafe { e(syscall!(RT_SIGSUSPEND, set as *const sigset_t, NSIG / 8)) as c_int }
fn sigsuspend(set: &sigset_t) -> Errno {
unsafe {
e_raw(syscall!(RT_SIGSUSPEND, set as *const sigset_t, NSIG / 8)).expect_err("must fail")
}
}
unsafe fn sigtimedwait(
+1 -1
View File
@@ -37,7 +37,7 @@ pub trait PalSignal: Pal {
oset: Option<&mut sigset_t>,
) -> Result<(), Errno>;
fn sigsuspend(set: &sigset_t) -> c_int;
fn sigsuspend(set: &sigset_t) -> Errno; // always fails
unsafe fn sigtimedwait(set: *const sigset_t, sig: *mut siginfo_t, tp: *const timespec)
-> c_int;
+5 -14
View File
@@ -246,7 +246,7 @@ impl PalSignal for Sys {
}
fn sigpending(set: &mut sigset_t) -> Result<(), Errno> {
*set = redox_rt::signal::currently_pending();
*set = redox_rt::signal::currently_pending_blocked();
Ok(())
}
@@ -264,20 +264,11 @@ impl PalSignal for Sys {
})
}
fn sigsuspend(set: &sigset_t) -> c_int {
//TODO: correct implementation
let mut oset = sigset_t::default();
if let Err(err) = redox_rt::signal::set_sigmask(Some(*set), Some(&mut oset)) {
Errno::from(err).sync();
return -1;
fn sigsuspend(set: &sigset_t) -> Errno {
match redox_rt::signal::wait_with_mask(*set) {
Ok(_) => unreachable!(),
Err(err) => err.into(),
}
//TODO: wait for signal
Self::sched_yield();
if let Err(err) = redox_rt::signal::set_sigmask(Some(oset), None) {
Errno::from(err).sync();
return -1;
}
0
}
unsafe fn sigtimedwait(