mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-24 01:43:22 +00:00
Reorganize the codebase
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
888853a6de
commit
271a16d492
20
services/libs/jinux-std/src/syscall/pause.rs
Normal file
20
services/libs/jinux-std/src/syscall/pause.rs
Normal file
@ -0,0 +1,20 @@
|
||||
use crate::{prelude::*, process::posix_thread::posix_thread_ext::PosixThreadExt, thread::Thread};
|
||||
|
||||
use super::SyscallReturn;
|
||||
|
||||
pub fn sys_pause() -> Result<SyscallReturn> {
|
||||
loop {
|
||||
let current_thread = current_thread!();
|
||||
// check sig_queue of current thread and process,
|
||||
// if there's any pending signal, break loop
|
||||
let posix_thread = current_thread.as_posix_thread().unwrap();
|
||||
if !posix_thread.sig_queues().lock().empty() || !current!().sig_queues().lock().empty() {
|
||||
break;
|
||||
}
|
||||
// there's no pending signal, yield execution
|
||||
// FIXME: set current thread interruptible here
|
||||
Thread::yield_now();
|
||||
}
|
||||
// handle signal before returning to user space
|
||||
return_errno_with_message!(Errno::ERESTART, "catch signal")
|
||||
}
|
Reference in New Issue
Block a user