pty-exec 0.1.0

A flexible, cross platform pty package
Documentation
  • Coverage
  • 75%
    6 out of 8 items documented1 out of 7 items with examples
  • Size
  • Source code size: 15.99 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 907.74 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 19s Average build duration of successful builds.
  • all releases: 19s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • jonathanforhan

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();