Bug #694
closedeof? call on a pty IO object causes application to exit
Description
=begin
dave[RUBY3/Book 18:08:15*] cat t.rb
require 'pty'
PTY.spawn("/usr/bin/ruby /usr/bin/irb") do |reader, writer, pid|
reader.eof?
end
dave[RUBY3/Book 18:08:52*] ruby -v t.rb
ruby 1.9.0 (2008-10-29 revision 15427) [i386-darwin9.5.0]
t.rb:4:in eof?': pty - exited: 82527 (PTY::ChildExited) from t.rb:4:in
block in '
from t.rb:3:in spawn' from t.rb:3:in
'
This problem prevents expect() from working.
=end
Updated by matz (Yukihiro Matsumoto) over 16 years ago
=begin
Hi,
In message "Re: [ruby-core:19583] [Bug #694] eof? call on a pty IO object causes application to exit"
on Wed, 29 Oct 2008 08:10:13 +0900, Dave Thomas redmine@ruby-lang.org writes:
|dave[RUBY3/Book 18:08:15*] cat t.rb
|
|require 'pty'
|
|PTY.spawn("/usr/bin/ruby /usr/bin/irb") do |reader, writer, pid|
| reader.eof?
|end
|
|dave[RUBY3/Book 18:08:52*] ruby -v t.rb
|
|ruby 1.9.0 (2008-10-29 revision 15427) [i386-darwin9.5.0]
|t.rb:4:in eof?': pty - exited: 82527 (PTY::ChildExited) | from t.rb:4:in
block in '
| from t.rb:3:in spawn' | from t.rb:3:in
'
|
|This problem prevents expect() from working.
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?
matz.
=end
Updated by pragdave (Dave Thomas) over 16 years ago
=begin
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 '
from t.rb:3:in spawn' from t.rb:3:in
'
=end
Updated by pragdave (Dave Thomas) over 16 years ago
=begin
On Oct 31, 2008, at 1:39 AM, Dave Thomas wrote:
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
enddave[~ 1:39:43] ruby -v t.rb
ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]
hellodave[~ 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:ineof?': pty - exited: 731 (PTY::ChildExited) from t.rb:4:in
block in '
from t.rb:3:inspawn' from t.rb:3:in
'
I wonder if the problem is that pty.c doesn't release the global lock,
and therefore any output from the subthread that's running the shell
is never seen?
Dave
=end
Updated by matz (Yukihiro Matsumoto) over 16 years ago
=begin
Hi,
In message "Re: [ruby-core:19687] Re: [Bug #694] eof? call on a pty IO object causes application to exit"
on Tue, 4 Nov 2008 03:54:38 +0900, Dave Thomas dave@pragprog.com writes:
|> 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 '
|> from t.rb:3:in spawn' |> from t.rb:3:in
'
|
|I wonder if the problem is that pty.c doesn't release the global lock,
|and therefore any output from the subthread that's running the shell
|is never seen?
Actually, 1.9 releases the global lock, so there was a chance for
subthread to send an exception to the main thread. I am not sure how
(and what) we can do.
matz.
=end
Updated by matz (Yukihiro Matsumoto) over 16 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
=begin
Applied in changeset r20298.
=end