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.2"
and this to your crate root:
extern crate pty;
pty::fork()
This function returns pty::Child
. It represents the child process and its PTY.
For example, the following code spawns tty(1)
command by pty::fork()
and outputs the result of the command.
extern crate pty;
extern crate libc;
use CString;
use Read;
use ptr;
use *;
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
Documentation
API documentation for latest version: http://hibariya.github.io/pty-rs/pty/index.html
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.