Handle child death
This commit is contained in:
parent
41bfce1f14
commit
c9c85aacab
@ -66,3 +66,9 @@ impl From<&str> for IO {
|
|||||||
Self(s.into())
|
Self(s.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct ChildDied();
|
||||||
|
|
||||||
|
impl Message for ChildDied {
|
||||||
|
type Result = ();
|
||||||
|
}
|
||||||
|
|||||||
13
src/lib.rs
13
src/lib.rs
@ -169,6 +169,16 @@ impl StreamHandler<ws::Message, ws::ProtocolError> for Websocket {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Handler<event::ChildDied> for Websocket {
|
||||||
|
type Result = ();
|
||||||
|
|
||||||
|
fn handle(&mut self, _msg: event::ChildDied, ctx: &mut <Self as Actor>::Context) {
|
||||||
|
trace!("Websocket <- ChildDied");
|
||||||
|
ctx.close(None);
|
||||||
|
ctx.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Represents a PTY backenActix WebSocket actor.d with attached child
|
/// Represents a PTY backenActix WebSocket actor.d with attached child
|
||||||
pub struct Terminal {
|
pub struct Terminal {
|
||||||
pty_write: Option<AsyncPtyMasterWriteHalf>,
|
pty_write: Option<AsyncPtyMasterWriteHalf>,
|
||||||
@ -246,6 +256,9 @@ impl Actor for Terminal {
|
|||||||
Err(e) => error!("Could not kill child with PID {}: {}", child.id(), e),
|
Err(e) => error!("Could not kill child with PID {}: {}", child.id(), e),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Notify the websocket that the child died.
|
||||||
|
self.ws.do_send(event::ChildDied());
|
||||||
|
|
||||||
Running::Stop
|
Running::Stop
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -40,6 +40,12 @@ SPDX-License-Identifier: BSD-3-Clause
|
|||||||
term.fit();
|
term.fit();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
sock.addEventListener('close', function() {
|
||||||
|
term.writeln("");
|
||||||
|
term.writeln("Connection closed.");
|
||||||
|
term.terminadoDetach(sock);
|
||||||
|
});
|
||||||
|
|
||||||
term.open(document.getElementById('terminal'));
|
term.open(document.getElementById('terminal'));
|
||||||
window.onresize = function() {term.fit();};
|
window.onresize = function() {term.fit();};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user