Skip to content

Instantly share code, notes, and snippets.

@kuinak
Created November 2, 2018 03:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kuinak/2f4cd2147fc7c855c16f702e1ab88ac2 to your computer and use it in GitHub Desktop.
Save kuinak/2f4cd2147fc7c855c16f702e1ab88ac2 to your computer and use it in GitHub Desktop.
PTY.spawn cmd do |i, o, pid|
Thread.new { o.putc STDIN.getch while !o.closed? }
t = Thread.new { putc i.readchar while !i.eof? }
Process::waitpid(pid) rescue nil
t.join
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment