Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #7331
| Newsgroups | comp.lang.ruby |
|---|---|
| Date | 2017-01-15 20:06 -0800 |
| References | <3c609641-b029-42b3-8308-9a7fcf107cf9@googlegroups.com> |
| Message-ID | <8369879e-9b91-4756-8d70-2d6d75bf90f4@googlegroups.com> (permalink) |
| Subject | Re: Question about writing and reading from a PTY |
| From | Chad Woolley <thewoolleyman@gmail.com> |
On Saturday, January 14, 2017 at 12:33:04 PM UTC-7, Chad Woolley wrote: > Hello, > > I'm trying to understand PTY behavior (I'm using Ruby 2.3.3). > > Specifically, in line 86 of this example (which should be executable if downloaded), why does the command not behave the same way via PTY as it does from a real terminal (which is to echo '>a<' or '>z<' to STDOUT)? > > https://gist.github.com/thewoolleyman/6a060574f22eafd42955812a1a2a7842/37491a2c756aa066444626294d65ab9208c95c7c#file-pty_check_test-rb-L86 > Figured this out myself. I wasn't reading the CR+LF chars appended by the 'puts' in the cmd. Fixed by adding a loop to ensure I read all chars (with the help of IO::ready? in 'io/wait' module). Here's the working version and output: https://gist.github.com/thewoolleyman/6a060574f22eafd42955812a1a2a7842/c76e0c62253c85033e73892319404eb9a40ab3e6#file-pty_check_test-rb-L42 https://gist.github.com/thewoolleyman/6a060574f22eafd42955812a1a2a7842/c76e0c62253c85033e73892319404eb9a40ab3e6#file-output-txt -- Chad
Back to comp.lang.ruby | Previous | Next — Previous in thread | Find similar
Question about writing and reading from a PTY Chad Woolley <thewoolleyman@gmail.com> - 2017-01-14 11:32 -0800 Re: Question about writing and reading from a PTY Chad Woolley <thewoolleyman@gmail.com> - 2017-01-15 20:06 -0800
csiph-web