PTY
The pty
crate provides pty::fork()
. That makes a parent process fork with new pseudo-terminal (PTY).
This crate depends on followings:
libc
library- POSIX environment
Usage
Add this to your Cargo.toml
:
[]
= "0.1"
and this to your crate root:
extern crate pty;
pty::fork() -> io::Result<(Child, Master)>
This function returns two values. pty::Child
represents a child process. pty::Master
represents master of a PTY.
For example, the following code spawns tty(1)
command by pty::fork()
.
extern crate libc;
extern crate pty;
use Read;
When run this, we get new PTY in the child process.
$ tty
/dev/pts/5
$ cargo run
Running `target/debug/example`
child tty is: /dev/pts/8
Contributing
- Fork it ( https://github.com/hibariya/pty-rs/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
License
Copyright (c) 2015 Hika Hibariya
Distributed under the MIT License.