Select should not return ETIME

This commit is contained in:
Jianfeng Jiang
2024-07-18 08:45:15 +00:00
committed by Tate, Hongliang Tian
parent 2766d95c18
commit 49eef0c094

View File

@ -52,13 +52,26 @@ pub fn sys_select(
nfds, readfds, writefds, exceptfds, timeout
);
let num_revents = do_select(
let num_revents = match do_select(
nfds,
readfds.as_mut(),
writefds.as_mut(),
exceptfds.as_mut(),
timeout,
)?;
) {
Ok(num_revents) => num_revents,
Err(e) if e.error() == Errno::ETIME => {
// The return value is zero if the timeout expires
// before any file descriptors became ready
return Ok(SyscallReturn::Return(0));
}
Err(e) => return Err(e),
};
// FIXME: The Linux select() and pselect6() system call
// modifies its timeout argument to reflect the amount of time not slept.
// However, the glibc wrapper function hides this behavior.
// Maybe we should follow the Linux behavior.
let set_fdset = |fdset_addr: Vaddr, fdset: Option<FdSet>| -> Result<()> {
if let Some(fdset) = fdset {