From 03a8c6229abb3abc1293231e847a566801bb2104 Mon Sep 17 00:00:00 2001 From: pjht Date: Fri, 8 Nov 2024 14:53:21 -0600 Subject: [PATCH] Convert exit into a kernel called RPC function --- proc_man_rpc/src/lib.rs | 13 +++---------- src/main.rs | 4 ++-- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/proc_man_rpc/src/lib.rs b/proc_man_rpc/src/lib.rs index 6356321..ce6cf56 100644 --- a/proc_man_rpc/src/lib.rs +++ b/proc_man_rpc/src/lib.rs @@ -66,13 +66,6 @@ impl Client { .unwrap() } - pub fn exit(&self, code: u8) { - postcard::from_bytes( - &rpc::send_call(self.0, PROTO, 4, &postcard::to_stdvec(&code).unwrap()).get_return(), - ) - .unwrap() - } - pub fn wait(&self, pid: u64, block: bool) -> Result { postcard::from_bytes( &rpc::send_call(self.0, PROTO, 5, &postcard::to_stdvec(&(pid, block)).unwrap()).get_return(), @@ -109,9 +102,9 @@ fn callback(call: IncomingCall) { let ret = postcard::to_stdvec(&server.get_cli_args(call.from)).unwrap(); call.send_return(&ret); } else if call.func == 4 { - let code = postcard::from_bytes(call.args()).unwrap(); - let ret = postcard::to_stdvec(&server.exit(call.from, code)).unwrap(); - call.send_return(&ret); + let (pid, code) = postcard::from_bytes(call.args()).unwrap(); + let _ = server.exit(pid, code); + //call.send_return(&ret); } else if call.func == 5 { let (pid, block) = postcard::from_bytes(call.args()).unwrap(); let ret = postcard::to_stdvec(&server.wait(call.from, pid, block)).unwrap(); diff --git a/src/main.rs b/src/main.rs index 59c374d..79c20fb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -78,8 +78,8 @@ impl proc_man_rpc::Server for Serv { .map_or(Vec::new(), |proc| proc.cli_args.clone()) } - fn exit(&self, from: u64, code: u8) { - if let Some(proc) = self.processes.write().get_mut(&from) { + fn exit(&self, pid: u64, code: u8) { + if let Some(proc) = self.processes.write().get_mut(&pid) { proc.status = ProcessStatus::Exited(code); } }