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 parking_lot::RwLock;
|
||||||
|
|
||||||
|
use std::ffi::OsString;
|
||||||
|
|
||||||
static SERVER: RwLock<Option<Box<dyn Server>>> = RwLock::new(None);
|
static SERVER: RwLock<Option<Box<dyn Server>>> = RwLock::new(None);
|
||||||
|
|
||||||
const PROTO: u16 = 8;
|
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 new_proc(&self, pid: u64, parent: Option<u64>) -> Result<(), Errno>;
|
||||||
fn set_stdio(&self, pid: u64, stdio: [Option<(u64, u64)>; 3]) -> 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 get_stdio(&self, from: u64) -> [Option<(u64, u64)>; 3];
|
||||||
fn set_cli_args(&self, pid: u64, args: Vec<String>) -> Result<(), Errno>;
|
fn set_cli_args(&self, pid: u64, args: Vec<OsString>) -> Result<(), Errno>;
|
||||||
fn get_cli_args(&self, from: u64) -> Vec<String>;
|
fn get_cli_args(&self, from: u64) -> Vec<OsString>;
|
||||||
fn exit(&self, from: u64, code: u8);
|
fn exit(&self, from: u64, code: u8);
|
||||||
fn wait(&self, from: u64, pid: u64, block: bool) -> Result<WaitResult, Errno>;
|
fn wait(&self, from: u64, pid: u64, block: bool) -> Result<WaitResult, Errno>;
|
||||||
}
|
}
|
||||||
@ -52,14 +54,14 @@ impl Client {
|
|||||||
.unwrap()
|
.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(
|
postcard::from_bytes(
|
||||||
&rpc::send_call(self.0, PROTO, 2, &postcard::to_stdvec(&(pid, args)).unwrap()).get_return(),
|
&rpc::send_call(self.0, PROTO, 2, &postcard::to_stdvec(&(pid, args)).unwrap()).get_return(),
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_cli_args(&self) -> Vec<String> {
|
pub fn get_cli_args(&self) -> Vec<OsString> {
|
||||||
postcard::from_bytes(
|
postcard::from_bytes(
|
||||||
&rpc::send_call(self.0, PROTO, 3, &[]).get_return(),
|
&rpc::send_call(self.0, PROTO, 3, &[]).get_return(),
|
||||||
)
|
)
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
|
ffi::OsString,
|
||||||
os::mikros::{self, ipc, syscalls, Errno},
|
os::mikros::{self, ipc, syscalls, Errno},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -13,7 +14,7 @@ enum ProcessStatus {
|
|||||||
|
|
||||||
struct Process {
|
struct Process {
|
||||||
stdio: [Option<(u64, u64)>; 3],
|
stdio: [Option<(u64, u64)>; 3],
|
||||||
cli_args: Vec<String>,
|
cli_args: Vec<OsString>,
|
||||||
status: ProcessStatus,
|
status: ProcessStatus,
|
||||||
parent: Option<u64>,
|
parent: Option<u64>,
|
||||||
children: Vec<u64>,
|
children: Vec<u64>,
|
||||||
@ -62,7 +63,8 @@ impl proc_man_rpc::Server for Serv {
|
|||||||
.map_or([None; 3], |proc| proc.stdio)
|
.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
|
self.processes
|
||||||
.write()
|
.write()
|
||||||
.get_mut(&pid)
|
.get_mut(&pid)
|
||||||
@ -71,7 +73,7 @@ impl proc_man_rpc::Server for Serv {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_cli_args(&self, from: u64) -> Vec<String> {
|
fn get_cli_args(&self, from: u64) -> Vec<OsString> {
|
||||||
self.processes
|
self.processes
|
||||||
.read()
|
.read()
|
||||||
.get(&from)
|
.get(&from)
|
||||||
|
Loading…
Reference in New Issue
Block a user