Project

General

Profile

Actions

Bug #694

closed

eof? call on a pty IO object causes application to exit

Added by pragdave (Dave Thomas) over 15 years ago. Updated almost 13 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
Backport:
[ruby-core:19583]

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

Actions #1

Updated by matz (Yukihiro Matsumoto) over 15 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 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

Actions #2

Updated by pragdave (Dave Thomas) over 15 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

Actions #3

Updated by pragdave (Dave Thomas) over 15 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
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?

Dave

=end

Actions #4

Updated by matz (Yukihiro Matsumoto) over 15 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 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

Actions #5

Updated by matz (Yukihiro Matsumoto) over 15 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
Applied in changeset r20298.
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0