On Oct 31, 2008, at 12:28 AM, Yukihiro Matsumoto wrote:

> pty uses exceptions to notify the process exit.  In my case, it
> terminated because I don't have /usr/bin/irb installed (it's renamed
> to /usr/bin/irb1.8).
>
> What do you expect?  Checking eof without raising exception?

That's what 1.8 seems to do.

Here's a slightly different version:

dave[~ 1:39:37] cat t.rb
require 'pty'

PTY.spawn("/bin/echo hello") do |reader, writer, pid|
   reader.eof?
   puts reader.gets
end

dave[~ 1:39:43] ruby -v t.rb
ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]
hello

dave[~ 1:39:45] /usr/local/rubybook/bin/ruby -v t.rb
ruby 1.9.0 (2008-10-29 revision 15427) [i386-darwin9.5.0]
t.rb:4:in `eof?': pty - exited: 731 (PTY::ChildExited)
	from t.rb:4:in `block in <main>'
	from t.rb:3:in `spawn'
	from t.rb:3:in `<main>'