|
@@ -9,7 +9,7 @@ use crate::kernel::constants::{
|
|
|
use crate::kernel::mem::PageBuffer;
|
|
use crate::kernel::mem::PageBuffer;
|
|
|
use crate::kernel::task::{
|
|
use crate::kernel::task::{
|
|
|
do_clone, futex_wait, futex_wake, FutexFlags, FutexOp, ProcessList, ProgramLoader,
|
|
do_clone, futex_wait, futex_wake, FutexFlags, FutexOp, ProcessList, ProgramLoader,
|
|
|
- RobustListHead, SignalAction, Thread, WaitType,
|
|
|
|
|
|
|
+ RobustListHead, SignalAction, Thread, WaitId, WaitType,
|
|
|
};
|
|
};
|
|
|
use crate::kernel::task::{parse_futexop, CloneArgs};
|
|
use crate::kernel::task::{parse_futexop, CloneArgs};
|
|
|
use crate::kernel::timer::sleep;
|
|
use crate::kernel::timer::sleep;
|
|
@@ -29,7 +29,6 @@ use eonix_hal::trap::TrapContext;
|
|
|
use eonix_mm::address::{Addr as _, VAddr};
|
|
use eonix_mm::address::{Addr as _, VAddr};
|
|
|
use eonix_runtime::task::Task;
|
|
use eonix_runtime::task::Task;
|
|
|
use eonix_sync::AsProof as _;
|
|
use eonix_sync::AsProof as _;
|
|
|
-use posix_types::constants::{P_ALL, P_PID};
|
|
|
|
|
use posix_types::ctypes::PtrT;
|
|
use posix_types::ctypes::PtrT;
|
|
|
use posix_types::signal::{SigAction, SigInfo, SigSet, Signal};
|
|
use posix_types::signal::{SigAction, SigInfo, SigSet, Signal};
|
|
|
use posix_types::stat::TimeVal;
|
|
use posix_types::stat::TimeVal;
|
|
@@ -216,6 +215,7 @@ fn execve(exec: *const u8, argv: *const PtrT, envp: *const PtrT) -> KResult<Sysc
|
|
|
|
|
|
|
|
let mut trap_ctx = thread.trap_ctx.borrow();
|
|
let mut trap_ctx = thread.trap_ctx.borrow();
|
|
|
*trap_ctx = TrapContext::new();
|
|
*trap_ctx = TrapContext::new();
|
|
|
|
|
+
|
|
|
trap_ctx.set_user_mode(true);
|
|
trap_ctx.set_user_mode(true);
|
|
|
trap_ctx.set_interrupt_enabled(true);
|
|
trap_ctx.set_interrupt_enabled(true);
|
|
|
trap_ctx.set_program_counter(load_info.entry_ip.addr());
|
|
trap_ctx.set_program_counter(load_info.entry_ip.addr());
|
|
@@ -252,16 +252,11 @@ enum WaitInfo {
|
|
|
|
|
|
|
|
fn do_waitid(
|
|
fn do_waitid(
|
|
|
thread: &Thread,
|
|
thread: &Thread,
|
|
|
- id_type: u32,
|
|
|
|
|
- _id: u32,
|
|
|
|
|
|
|
+ wait_id: WaitId,
|
|
|
info: WaitInfo,
|
|
info: WaitInfo,
|
|
|
options: u32,
|
|
options: u32,
|
|
|
rusage: *mut RUsage,
|
|
rusage: *mut RUsage,
|
|
|
) -> KResult<u32> {
|
|
) -> KResult<u32> {
|
|
|
- if id_type != P_ALL {
|
|
|
|
|
- unimplemented!("waitid with id_type {id_type}");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
if !rusage.is_null() {
|
|
if !rusage.is_null() {
|
|
|
unimplemented!("waitid with rusage pointer");
|
|
unimplemented!("waitid with rusage pointer");
|
|
|
}
|
|
}
|
|
@@ -272,6 +267,7 @@ fn do_waitid(
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
let Some(wait_object) = Task::block_on(thread.process.wait(
|
|
let Some(wait_object) = Task::block_on(thread.process.wait(
|
|
|
|
|
+ wait_id,
|
|
|
options.contains(UserWaitOptions::WNOHANG),
|
|
options.contains(UserWaitOptions::WNOHANG),
|
|
|
options.contains(UserWaitOptions::WUNTRACED),
|
|
options.contains(UserWaitOptions::WUNTRACED),
|
|
|
options.contains(UserWaitOptions::WCONTINUED),
|
|
options.contains(UserWaitOptions::WCONTINUED),
|
|
@@ -310,15 +306,10 @@ fn waitid(
|
|
|
options: u32,
|
|
options: u32,
|
|
|
rusage: *mut RUsage,
|
|
rusage: *mut RUsage,
|
|
|
) -> KResult<u32> {
|
|
) -> KResult<u32> {
|
|
|
|
|
+ let wait_id = WaitId::from_type_and_id(id_type, id)?;
|
|
|
|
|
+
|
|
|
if let Some(info) = NonNull::new(info) {
|
|
if let Some(info) = NonNull::new(info) {
|
|
|
- do_waitid(
|
|
|
|
|
- thread,
|
|
|
|
|
- id_type,
|
|
|
|
|
- id,
|
|
|
|
|
- WaitInfo::SigInfo(info),
|
|
|
|
|
- options,
|
|
|
|
|
- rusage,
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ do_waitid(thread, wait_id, WaitInfo::SigInfo(info), options, rusage)
|
|
|
} else {
|
|
} else {
|
|
|
/*
|
|
/*
|
|
|
* According to POSIX.1-2008, an application calling waitid() must
|
|
* According to POSIX.1-2008, an application calling waitid() must
|
|
@@ -333,24 +324,21 @@ fn waitid(
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#[eonix_macros::define_syscall(SYS_WAIT4)]
|
|
#[eonix_macros::define_syscall(SYS_WAIT4)]
|
|
|
-fn wait4(waitpid: u32, arg1: *mut u32, options: u32, rusage: *mut RUsage) -> KResult<u32> {
|
|
|
|
|
|
|
+fn wait4(wait_id: i32, arg1: *mut u32, options: u32, rusage: *mut RUsage) -> KResult<u32> {
|
|
|
let waitinfo = if let Some(status) = NonNull::new(arg1) {
|
|
let waitinfo = if let Some(status) = NonNull::new(arg1) {
|
|
|
WaitInfo::Status(status)
|
|
WaitInfo::Status(status)
|
|
|
} else {
|
|
} else {
|
|
|
WaitInfo::None
|
|
WaitInfo::None
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- let idtype = match waitpid {
|
|
|
|
|
- u32::MAX => P_ALL,
|
|
|
|
|
- _ => P_PID,
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ let wait_id = WaitId::from_id(wait_id, thread);
|
|
|
|
|
|
|
|
- do_waitid(thread, idtype, waitpid, waitinfo, options, rusage)
|
|
|
|
|
|
|
+ do_waitid(thread, wait_id, waitinfo, options, rusage)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#[cfg(target_arch = "x86_64")]
|
|
#[cfg(target_arch = "x86_64")]
|
|
|
#[eonix_macros::define_syscall(SYS_WAITPID)]
|
|
#[eonix_macros::define_syscall(SYS_WAITPID)]
|
|
|
-fn waitpid(waitpid: u32, arg1: *mut u32, options: u32) -> KResult<u32> {
|
|
|
|
|
|
|
+fn waitpid(waitpid: i32, arg1: *mut u32, options: u32) -> KResult<u32> {
|
|
|
sys_wait4(thread, waitpid, arg1, options, core::ptr::null_mut())
|
|
sys_wait4(thread, waitpid, arg1, options, core::ptr::null_mut())
|
|
|
}
|
|
}
|
|
|
|
|
|