From dd38365992c9389ea24000ca83be9bc2b7b7edd9 Mon Sep 17 00:00:00 2001 From: pjht Date: Tue, 11 Jun 2024 21:56:09 -0500 Subject: [PATCH] Add basic support for running programs off disk for mikros --- library/std/src/sys/pal/mikros/process.rs | 27 ++++++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/library/std/src/sys/pal/mikros/process.rs b/library/std/src/sys/pal/mikros/process.rs index 2445d9073db..f2d43d06c0a 100644 --- a/library/std/src/sys/pal/mikros/process.rs +++ b/library/std/src/sys/pal/mikros/process.rs @@ -104,7 +104,20 @@ pub fn spawn( _default: Stdio, _needs_stdin: bool, ) -> io::Result<(Process, StdioPipes)> { - unsupported() + let path = Path::new(&self.program); + let binary = crate::fs::read(path).unwrap(); + let (space, entry) = crate::os::mikros::loader::Loader::load(&binary); + super::syscalls::new_process(entry as _, space).unwrap(); + Ok(( + Process { + dummy: () + }, + StdioPipes { + stdin: None, + stdout: None, + stderr: None, + } + )) } pub fn output(&mut self) -> io::Result<(ExitStatus, Vec, Vec)> { @@ -277,23 +290,25 @@ fn from(code: u8) -> Self { } } -pub struct Process(!); +pub struct Process { + dummy: () +} impl Process { pub fn id(&self) -> u32 { - self.0 + todo!() } pub fn kill(&mut self) -> io::Result<()> { - self.0 + todo!() } pub fn wait(&mut self) -> io::Result { - self.0 + todo!() } pub fn try_wait(&mut self) -> io::Result> { - self.0 + todo!() } }