diff --git a/proc_man_rpc/src/lib.rs b/proc_man_rpc/src/lib.rs index ce6cf56..28915ef 100644 --- a/proc_man_rpc/src/lib.rs +++ b/proc_man_rpc/src/lib.rs @@ -9,6 +9,8 @@ pub use proc_man_structs::WaitResult; use parking_lot::RwLock; +use std::ffi::OsString; + static SERVER: RwLock>> = RwLock::new(None); const PROTO: u16 = 8; @@ -17,8 +19,8 @@ pub trait Server: Send + Sync { fn new_proc(&self, pid: u64, parent: Option) -> Result<(), Errno>; fn set_stdio(&self, pid: u64, stdio: [Option<(u64, u64)>; 3]) -> Result<(), Errno>; fn get_stdio(&self, from: u64) -> [Option<(u64, u64)>; 3]; - fn set_cli_args(&self, pid: u64, args: Vec) -> Result<(), Errno>; - fn get_cli_args(&self, from: u64) -> Vec; + fn set_cli_args(&self, pid: u64, args: Vec) -> Result<(), Errno>; + fn get_cli_args(&self, from: u64) -> Vec; fn exit(&self, from: u64, code: u8); fn wait(&self, from: u64, pid: u64, block: bool) -> Result; } @@ -52,14 +54,14 @@ impl Client { .unwrap() } - pub fn set_cli_args(&self, pid: u64, args: Vec) -> Result<(), Errno> { + pub fn set_cli_args(&self, pid: u64, args: Vec) -> Result<(), Errno> { postcard::from_bytes( &rpc::send_call(self.0, PROTO, 2, &postcard::to_stdvec(&(pid, args)).unwrap()).get_return(), ) .unwrap() } - pub fn get_cli_args(&self) -> Vec { + pub fn get_cli_args(&self) -> Vec { postcard::from_bytes( &rpc::send_call(self.0, PROTO, 3, &[]).get_return(), ) @@ -95,7 +97,7 @@ fn callback(call: IncomingCall) { let ret = postcard::to_stdvec(&server.get_stdio(call.from)).unwrap(); call.send_return(&ret); } else if call.func == 2 { - let (pid, args )= postcard::from_bytes(call.args()).unwrap(); + let (pid, args)= postcard::from_bytes(call.args()).unwrap(); let ret = postcard::to_stdvec(&server.set_cli_args(pid, args)).unwrap(); call.send_return(&ret); } else if call.func == 3 { diff --git a/src/main.rs b/src/main.rs index 79c20fb..289e2b3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,6 @@ use std::{ collections::HashMap, + ffi::OsString, os::mikros::{self, ipc, syscalls, Errno}, }; @@ -13,7 +14,7 @@ enum ProcessStatus { struct Process { stdio: [Option<(u64, u64)>; 3], - cli_args: Vec, + cli_args: Vec, status: ProcessStatus, parent: Option, children: Vec, @@ -62,7 +63,8 @@ impl proc_man_rpc::Server for Serv { .map_or([None; 3], |proc| proc.stdio) } - fn set_cli_args(&self, pid: u64, args: Vec) -> Result<(), Errno> { + fn set_cli_args(&self, pid: u64, args: Vec) -> Result<(), Errno> { + eprintln!("Set CLI args for PID {} to {:?}", pid, args); self.processes .write() .get_mut(&pid) @@ -71,7 +73,7 @@ impl proc_man_rpc::Server for Serv { Ok(()) } - fn get_cli_args(&self, from: u64) -> Vec { + fn get_cli_args(&self, from: u64) -> Vec { self.processes .read() .get(&from)