Add process stuff

This commit is contained in:
Mark Poliakov 2023-07-25 10:49:00 +03:00
parent a3456a5b99
commit e0774b4d39
3 changed files with 22 additions and 0 deletions

View File

@ -12,6 +12,7 @@ pub use abi::path;
pub mod alloc;
pub mod debug;
pub mod netc;
pub mod process;
pub mod sys;
pub mod time;

6
src/process.rs Normal file
View File

@ -0,0 +1,6 @@
//! Process management data types
pub use abi::process::{SpawnOption, SpawnOptions};
/// Status code returned when a process terminates
pub type ExitStatus = i32;

View File

@ -7,6 +7,7 @@ use abi::{
DirectoryEntry, FileAttr, FileMode, MountOptions, OpenOptions, RawFd, SeekFrom,
UnmountOptions,
},
process::SpawnOptions,
syscall::SyscallFunction,
};
@ -316,3 +317,17 @@ pub unsafe fn get_metadata(
pub unsafe fn seek(fd: RawFd, pos: SeekFrom) -> Result<u64, Error> {
u64::from_syscall_result(syscall!(SyscallFunction::Seek, argn!(fd.0), argn!(u64::from(pos))))
}
///
pub unsafe fn spawn(options: &SpawnOptions<'_>) -> Result<u32, Error> {
u32::from_syscall_result(syscall!(SyscallFunction::Spawn, argp!(options as *const _)))
}
///
pub unsafe fn wait_process(pid: u32, status: &mut i32) -> Result<(), Error> {
<()>::from_syscall_result(syscall!(
SyscallFunction::WaitProcess,
argn!(pid),
argp!(status as *mut _)
))
}