Implement SA_RESTART for read and write.

This commit is contained in:
4lDO2
2024-07-15 23:24:41 +02:00
parent 3cd21243ec
commit bcce7e18db
5 changed files with 64 additions and 1 deletions
+6
View File
@@ -2,16 +2,22 @@ use syscall::error::{Result, Error, EINTR};
use crate::arch::manually_enter_trampoline;
use crate::signal::tmp_disable_signals;
use crate::Tcb;
#[inline]
fn wrapper(mut f: impl FnMut() -> Result<usize>) -> Result<usize> {
loop {
let _guard = tmp_disable_signals();
let rt_sigarea = unsafe { &Tcb::current().unwrap().os_specific };
let res = f();
if res == Err(Error::new(EINTR)) {
unsafe {
manually_enter_trampoline();
}
if unsafe { (*rt_sigarea.arch.get()).last_sig_was_restart } {
continue;
}
}
return res;