From 5f6b42d5345f923a3819f52aa2cfe03a1b6c6f31 Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Fri, 30 Oct 2020 10:14:02 +0800 Subject: [PATCH] kernel: hosted: print pid of a process that exited Signed-off-by: Sean Cross --- kernel/src/arch/hosted.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/src/arch/hosted.rs b/kernel/src/arch/hosted.rs index fc799ca71..258d60fc0 100644 --- a/kernel/src/arch/hosted.rs +++ b/kernel/src/arch/hosted.rs @@ -85,13 +85,13 @@ fn handle_connection( ServerPacketWithData([usize; 9], Vec), } - fn conn_thread(mut conn: TcpStream, sender: Sender) { + fn conn_thread(mut conn: TcpStream, sender: Sender, pid: PID) { loop { let mut raw_data = [0u8; 9 * std::mem::size_of::()]; - if let Err(_e) = conn.read_exact(&mut raw_data) { + if let Err(e) = conn.read_exact(&mut raw_data) { println!( - "KERNEL(?): Client disconnected: {} ({:?}). Shutting down virtual process.", - _e, _e + "KERNEL({}): client disconnected: {} -- shutting down virtual process", + pid, e ); sender.send(ServerMessage::Exit).ok(); return; @@ -140,7 +140,7 @@ fn handle_connection( std::thread::Builder::new() .name(format!("PID {}: client connection thread", pid)) .spawn(move || { - conn_thread(conn, conn_sender); + conn_thread(conn, conn_sender, pid); }) .unwrap();