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
Specifically, this is expected (which is what happens if you run the cmd from the command line:
```
$ ruby -e 'require "io/console"; while(i=$stdin.getch) do puts ">#{i}<"; if i =~ /z/; break; end; end'
a<
z<
$ # back at prompt
```
But this program instead does this:
```
cmd: ruby -e 'require "io/console"; while(i=$stdin.getch) do puts ">#{i}<"; if i =~ /z/; break; end; end'
Process with pid 24846 is running
PTY::check for process with pid 24846 is : nil
writing "a"
reading...
output_buffer contents:
a<
Process with pid 24846 is running
PTY::check for process with pid 24846 is : nil
writing "z"
reading...
output_buffer contents:
a<
z
Process with pid 24846 is running
PTY::check for process with pid 24846 is : nil
a<
z
(program exits)
```
I'm aware that a real program would have no sleeps, and would have more sophisticated handling of input/output stream blocking, interrupts, exceptions, etc, but I'm trying to make this example as simple as possible.
I suspect that the program is not processing the last "z" input character, and thus not exiting, but I I'm not sure how to prove that, nor do I understand why it behaves differently in a real terminal.
Thanks!
-- Chad
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)