MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / pty_read

Function pty_read

cloud-hypervisor/tests/common/utils.rs:778–797  ·  view source on GitHub ↗
(mut pty: std::fs::File)

Source from the content-addressed store, hash-verified

776}
777
778pub(super) fn pty_read(mut pty: std::fs::File) -> Receiver<String> {
779 let (tx, rx) = mpsc::channel::<String>();
780 thread::spawn(move || {
781 loop {
782 thread::sleep(std::time::Duration::new(1, 0));
783 let mut buf = [0; 512];
784 match pty.read(&mut buf) {
785 Ok(_bytes) => {
786 let output = std::str::from_utf8(&buf).unwrap().to_string();
787 match tx.send(output) {
788 Ok(_) => (),
789 Err(_) => break,
790 }
791 }
792 Err(_) => break,
793 }
794 }
795 });
796 rx
797}
798
799pub(crate) fn get_pty_path(api_socket: &str, pty_type: &str) -> PathBuf {
800 let (cmd_success, cmd_output, _) = remote_command_w_output(api_socket, "info", None);

Callers 1

_test_pty_interactionFunction · 0.85

Calls 3

newFunction · 0.85
readMethod · 0.45
sendMethod · 0.45

Tested by

no test coverage detected