Skip to content

Commit

Permalink
fix(terminal): stop zombie bash processes from stacking up
Browse files Browse the repository at this point in the history
Closes #24
  • Loading branch information
ravenclaw900 committed Nov 8, 2021
1 parent 3cab7fa commit cdaa017
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/backend/src/terminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ pub async fn term_handler(socket: warp::ws::WebSocket) {
// Stop reader
(*cmd_write.read().await)
.pty()
.write_all("exit".as_bytes())
.write_all("exit\n".as_bytes())
.unwrap();
});

let pty_reader = tokio::spawn(async move {
loop {
let mut data = [0; 1024];
let mut data = [0; 512];
let lock = cmd_read.read().await;
match (*lock).pty().read(&mut data) {
Ok(_) => {}
Expand All @@ -73,8 +73,8 @@ pub async fn term_handler(socket: warp::ws::WebSocket) {
// Wait for threads to exit
tokio::try_join!(pty_writer, pty_reader).unwrap();

// Process should be safe to kill after exiting
(*cmd.write().await).kill().unwrap();
// Reap PID
(*cmd.write().await).wait().unwrap();

log::info!("Closed terminal");
}

0 comments on commit cdaa017

Please sign in to comment.