#tokio #process #pty #asynchronously #interact #child #pseudotty

tokio-pty-process

Interact with a child process through a pseudo-TTY, asynchronously using Tokio

6 releases (3 breaking)

Uses old Rust 2015

0.4.0 Jun 5, 2019
0.3.2 Apr 17, 2019
0.3.1 Dec 29, 2018
0.3.0 Oct 11, 2018
0.1.0 May 27, 2018

#746 in Unix APIs

Download history 31/week @ 2023-11-20 7/week @ 2023-11-27 2/week @ 2023-12-04 7/week @ 2023-12-11 9/week @ 2023-12-18 3/week @ 2023-12-25 6/week @ 2024-01-01 8/week @ 2024-01-08 1/week @ 2024-01-15 5/week @ 2024-01-22 9/week @ 2024-02-05 23/week @ 2024-02-12 137/week @ 2024-02-19 257/week @ 2024-02-26 227/week @ 2024-03-04

646 downloads per month
Used in 4 crates (3 directly)

MIT/Apache

33KB
512 lines

tokio-pty-process

Spawn a child process that is connected to a pseudo-TTY, interacting with it asynchronously using Tokio.

This code is essentially a mashup of tokio-process and pty-rs. It is more strongly derived from the former.

This project is copyright its authors and licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in tokio-pty-process by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


lib.rs:

Spawn a child process under a pseudo-TTY, interacting with it asynchronously using Tokio.

A pseudo-terminal (or “pseudo-TTY” or “PTY”) is a special Unix file handle that models the kind of text terminal through which users used to interact with computers. A PTY enables a specialized form of bidirectional interprocess communication that a variety of user-facing Unix programs take advantage of.

The basic way to use this crate is:

  1. Create a Tokio Reactor that will handle all of your asynchronous I/O.
  2. Create an AsyncPtyMaster that represents your ownership of an OS pseudo-terminal.
  3. Use your master and the spawn_pty_async or spawn_pty_async_raw functions of the CommandExt extension trait, which extends std::process::Command, to launch a child process that is connected to your master.
  4. Optionally control the child process (e.g. send it signals) through the Child value returned by that function.

This crate only works on Unix since pseudo-terminals are a Unix-specific concept.

The Child type is largely copied from Alex Crichton’s tokio-process crate.

Dependencies

~6MB
~89K SLoC