pty-exec

Crates.iopty-exec
lib.rspty-exec
version0.1.0
sourcesrc
created_at2023-08-02 23:58:58.97563
updated_at2023-08-02 23:58:58.97563
descriptionA flexible, cross platform pty package
homepage
repository
max_upload_size
id933248
size14,872
(jonathanforhan)

documentation

README

pty-exec

use std::os::fd::{AsRawFd, FromRawFd};
use pty_exec::Pty;

// spawn Pty
let pty = Pty::spawn(move |_fd, res| {
    println!("{}", res.unwrap());
}, move |fd| {
    println!("{fd} died");
})?;

// (optional) create new pty, this maintains the on_read and on_death callbacks
// this means a RawFd can be passed to client like in a tauri app
let pty = unsafe { Pty::from_raw_fd(pty.as_raw_fd()) };

// write to original pty with new pty from_raw_fd
pty.write("echo 'Hello, World'\r")?;

pty.kill();
Commit count: 0

cargo fmt