diff --git a/src/lib.rs b/src/lib.rs index 33e3e2b0..4be74528 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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; diff --git a/src/process.rs b/src/process.rs new file mode 100644 index 00000000..1795b90b --- /dev/null +++ b/src/process.rs @@ -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; diff --git a/src/sys.rs b/src/sys.rs index 4b20d8b8..105f39a1 100644 --- a/src/sys.rs +++ b/src/sys.rs @@ -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::from_syscall_result(syscall!(SyscallFunction::Seek, argn!(fd.0), argn!(u64::from(pos)))) } + +/// +pub unsafe fn spawn(options: &SpawnOptions<'_>) -> Result { + 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 _) + )) +}