Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Control a Shell With pty-shell

Hibariya Hi
December 23, 2015

Control a Shell With pty-shell

Introducing pty-shell which is an extension of pty crate

Hibariya Hi

December 23, 2015

Transcript

18 slides
  1. pty

  2. It’s Not Enough My original purpose is to control STDIO

    of a shell process. To accomplish it, I have to do followings. • Do exec a shell command (e.g. bash) • Make parent process enter raw-mode • Connect parent STDIO to child STDIO • Notify winsize changes from parent to child
  3. pty-shell: Control STDIO of a Shell https://github.com/hibariya/pty-shell Spawns a new

    shell and connects to its parent’ s STDIO. Then makes the parent act as proxy. Anyway, you can hook the INPUT/OUTPUT of a shell process. For example: you can play any sound effect and/or you can record or share output of the terminal.
  4. use pty; use pty_shell::{PtyProxy, PtyHandler}; struct MyHandler; impl PtyHandler for

    MyHandler { fn input(&mut self, input: Vec<u8>) { // do something with input } fn output(&mut self, output: Vec<u8>) { // do something with output } }

More Decks by Hibariya Hi

Other Decks in Technology