Change CLI argument type to OsString
This commit is contained in:
parent
03a8c6229a
commit
c876df4554
@ -9,6 +9,8 @@ pub use proc_man_structs::WaitResult;
|
||||
|
||||
use parking_lot::RwLock;
|
||||
|
||||
use std::ffi::OsString;
|
||||
|
||||
static SERVER: RwLock<Option<Box<dyn Server>>> = RwLock::new(None);
|
||||
|
||||
const PROTO: u16 = 8;
|
||||
@ -17,8 +19,8 @@ pub trait Server: Send + Sync {
|
||||
fn new_proc(&self, pid: u64, parent: Option<u64>) -> 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<String>) -> Result<(), Errno>;
|
||||
fn get_cli_args(&self, from: u64) -> Vec<String>;
|
||||
fn set_cli_args(&self, pid: u64, args: Vec<OsString>) -> Result<(), Errno>;
|
||||
fn get_cli_args(&self, from: u64) -> Vec<OsString>;
|
||||
fn exit(&self, from: u64, code: u8);
|
||||
fn wait(&self, from: u64, pid: u64, block: bool) -> Result<WaitResult, Errno>;
|
||||
}
|
||||
@ -52,14 +54,14 @@ impl Client {
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
pub fn set_cli_args(&self, pid: u64, args: Vec<String>) -> Result<(), Errno> {
|
||||
pub fn set_cli_args(&self, pid: u64, args: Vec<OsString>) -> 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<String> {
|
||||
pub fn get_cli_args(&self) -> Vec<OsString> {
|
||||
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 {
|
||||
|
@ -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<String>,
|
||||
cli_args: Vec<OsString>,
|
||||
status: ProcessStatus,
|
||||
parent: Option<u64>,
|
||||
children: Vec<u64>,
|
||||
@ -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<String>) -> Result<(), Errno> {
|
||||
fn set_cli_args(&self, pid: u64, args: Vec<OsString>) -> 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<String> {
|
||||
fn get_cli_args(&self, from: u64) -> Vec<OsString> {
|
||||
self.processes
|
||||
.read()
|
||||
.get(&from)
|
||||
|
Loading…
Reference in New Issue
Block a user