1
0
mirror of https://github.com/rcore-os/rCore.git synced 2024-11-22 08:06:17 +04:00

Fix has_signal_to_do

This commit is contained in:
Jiajie Chen 2020-06-18 20:44:46 +08:00
parent 4613fef11b
commit 252520f336
7 changed files with 29 additions and 28 deletions

View File

@ -11,7 +11,6 @@ use rcore_fs::vfs::{FileType, FsError, INode, MMapArea, Metadata, PollStatus, Re
use rcore_memory::memory_set::handler::File;
use crate::fs::fcntl::{O_APPEND, O_NONBLOCK};
use crate::signal::{do_signal, has_signal_to_do};
use crate::sync::SpinLock as Mutex;
use crate::syscall::SysError::{EAGAIN, ESPIPE};
use bitflags::_core::cell::Cell;
@ -123,9 +122,10 @@ impl FileHandle {
return Ok(read_len);
}
Err(FsError::Again) => {
if has_signal_to_do() {
return Err(Interrupted);
}
// TODO: async
//if has_signal_to_do() {
//return Err(Interrupted);
//}
//thread::yield_now();
}
Err(err) => {

View File

@ -45,8 +45,13 @@ pub const FIOCLEX: usize = 0x6601;
// rustc using pipe and ioctl pipe file with this request id
// for non-blocking/blocking IO control setting
#[cfg(not(target_arch = "mips"))]
pub const FIONBIO: usize = 0x5421;
#[cfg(target_arch = "mips")]
pub const FIONBIO: usize = 0x667E;
// ref: https://www.man7.org/linux/man-pages/man3/termios.3.html
// c_lflag constants
bitflags! {
pub struct LocalModes : u32 {
const ISIG = 0o000001;

View File

@ -132,26 +132,6 @@ pub struct SignalFrame {
pub ret_code: [u8; 7], // call sys_sigreturn
}
pub fn has_signal_to_do() -> bool {
let thread = unsafe { current_thread() };
unsafe {
current_thread()
.proc
.lock()
.sig_queue
.iter()
.find(|(info, tid)| {
let tid = *tid;
tid == -1
//(tid == -1 || tid as usize == current().id())
&& !thread
.sig_mask
.contains(FromPrimitive::from_i32(info.signo).unwrap())
})
.is_some()
}
}
pub fn do_signal(tf: &mut TrapFrame) {
let thread = unsafe { current_thread() };
let mut process = unsafe { current_thread().proc.lock() };

View File

@ -25,7 +25,6 @@ use crate::fs::epoll::EpollInstance;
use crate::fs::fcntl::{FD_CLOEXEC, F_SETFD, O_CLOEXEC, O_NONBLOCK};
use crate::fs::FileLike;
use crate::process::Process;
use crate::signal::has_signal_to_do;
use crate::syscall::SysError::{EINTR, EINVAL, ESPIPE};
use rcore_fs::vfs::PollStatus;

View File

@ -2,7 +2,7 @@
use super::*;
use crate::fs::FileLike;
use crate::signal::{has_signal_to_do, send_signal, Signal};
use crate::signal::{send_signal, Signal};
use crate::{
sync::{wait_for_event, Event},
syscall::SysError::{EINTR, ESRCH},
@ -378,7 +378,7 @@ impl Syscall<'_> {
if !time.is_zero() {
// TODO: handle spurious wakeup
//thread::sleep(time.to_duration());
if has_signal_to_do() {
if self.has_signal_to_do() {
return Err(EINTR);
}
}

View File

@ -5,6 +5,23 @@ use crate::syscall::{SysResult, Syscall};
use num::FromPrimitive;
impl Syscall<'_> {
pub fn has_signal_to_do(&self) -> bool {
self.thread
.proc
.lock()
.sig_queue
.iter()
.find(|(info, tid)| {
let tid = *tid;
(tid == -1 || tid as usize == self.thread.tid)
&& !self
.thread
.sig_mask
.contains(FromPrimitive::from_i32(info.signo).unwrap())
})
.is_some()
}
pub fn sys_rt_sigaction(
&self,
signum: usize,

2
user

@ -1 +1 @@
Subproject commit 2a0ae80cc8c2114a151ccb5f1897d8daa9555dba
Subproject commit 4b6b987ed56c450510402ca56d972781d5e77c31