Project

General

Profile

Bug #13191

sample/pty/shl.rb がうまく動かない

Added by znz (Kazuhiro NISHIYAMA) over 2 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-dev:49974]

Description

sample/pty/shl.rb で c で起動したシェルを exit で終了した時に終了がうまく検知できないようです。

r57530 の修正がないと 1.8.6 でも動かなかったので、その修正をしたもので試したのですが、1.8.6 や 1.8.7 で試すとメインスレッドに PTY::ChildExited が発生して、writer メソッドの STDIN.getc が中断して rescue 節で 'Exit' が返り、うまく終了が検知できました。

たぶんネイティブスレッドを使うようになった 1.9 以降(?)だと思うのですが、PTY::ChildExited が発生せず、ps コマンドで確認するとシェルが defunct になっています。

ここまでは調べられたのですが、ちょっと調べた限りでは、これが sample/pty/shl.rb のバグなのか ext/pty のバグなのかわかりませんでした。

Associated revisions

Revision 57530
Added by znz (Kazuhiro NISHIYAMA) over 2 years ago

sample/pty/shl.rb: update sample

  • Specify frozen_string_literal: true.
  • Fix TypeError of raise.
  • Use a character literal instead of Integer.

Revision 0d98fd88
Added by nobu (Nobuyoshi Nakada) over 2 years ago

pty/shl.rb: update [ci skip]

  • sample/pty/shl.rb: stop writer loop when the child exited. PTY::ChildExited no longer raises asynchronously since r20298. [ruby-dev:49974] [Bug #13191]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57531 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 57531
Added by nobu (Nobuyoshi Nakada) over 2 years ago

pty/shl.rb: update [ci skip]

  • sample/pty/shl.rb: stop writer loop when the child exited. PTY::ChildExited no longer raises asynchronously since r20298. [ruby-dev:49974] [Bug #13191]

Revision 57531
Added by nobu (Nobuyoshi Nakada) over 2 years ago

pty/shl.rb: update [ci skip]

  • sample/pty/shl.rb: stop writer loop when the child exited. PTY::ChildExited no longer raises asynchronously since r20298. [ruby-dev:49974] [Bug #13191]

Revision 57531
Added by nobu (Nobuyoshi Nakada) over 2 years ago

pty/shl.rb: update [ci skip]

  • sample/pty/shl.rb: stop writer loop when the child exited. PTY::ChildExited no longer raises asynchronously since r20298. [ruby-dev:49974] [Bug #13191]

Revision 69b64711
Added by nobu (Nobuyoshi Nakada) over 2 years ago

pty/shl.rb: update [ci skip]

  • sample/pty/shl.rb: use io/console instead of stty. [ruby-dev:49974] [Bug #13191]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57532 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 57532
Added by nobu (Nobuyoshi Nakada) over 2 years ago

pty/shl.rb: update [ci skip]

  • sample/pty/shl.rb: use io/console instead of stty. [ruby-dev:49974] [Bug #13191]

Revision 57532
Added by nobu (Nobuyoshi Nakada) over 2 years ago

pty/shl.rb: update [ci skip]

  • sample/pty/shl.rb: use io/console instead of stty. [ruby-dev:49974] [Bug #13191]

Revision 57532
Added by nobu (Nobuyoshi Nakada) over 2 years ago

pty/shl.rb: update [ci skip]

  • sample/pty/shl.rb: use io/console instead of stty. [ruby-dev:49974] [Bug #13191]

Revision b163b3ff
Added by nobu (Nobuyoshi Nakada) over 2 years ago

pty/shl.rb: update [ci skip]

  • sample/pty/shl.rb: do not manage array length separately. [ruby-dev:49974] [Bug #13191]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57533 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 57533
Added by nobu (Nobuyoshi Nakada) over 2 years ago

pty/shl.rb: update [ci skip]

  • sample/pty/shl.rb: do not manage array length separately. [ruby-dev:49974] [Bug #13191]

Revision 57533
Added by nobu (Nobuyoshi Nakada) over 2 years ago

pty/shl.rb: update [ci skip]

  • sample/pty/shl.rb: do not manage array length separately. [ruby-dev:49974] [Bug #13191]

Revision 57533
Added by nobu (Nobuyoshi Nakada) over 2 years ago

pty/shl.rb: update [ci skip]

  • sample/pty/shl.rb: do not manage array length separately. [ruby-dev:49974] [Bug #13191]

Revision cd6d9193
Added by nobu (Nobuyoshi Nakada) over 2 years ago

pty/shl.rb: update [ci skip]

  • sample/pty/shl.rb: leap exited child process. [ruby-dev:49974] [Bug #13191]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 57537
Added by nobu (Nobuyoshi Nakada) over 2 years ago

pty/shl.rb: update [ci skip]

  • sample/pty/shl.rb: leap exited child process. [ruby-dev:49974] [Bug #13191]

Revision 57537
Added by nobu (Nobuyoshi Nakada) over 2 years ago

pty/shl.rb: update [ci skip]

  • sample/pty/shl.rb: leap exited child process. [ruby-dev:49974] [Bug #13191]

Revision 57537
Added by nobu (Nobuyoshi Nakada) over 2 years ago

pty/shl.rb: update [ci skip]

  • sample/pty/shl.rb: leap exited child process. [ruby-dev:49974] [Bug #13191]

Revision 657a8067
Added by usa (Usaku NAKAMURA) over 2 years ago

merge revision(s) 57531,57532,57533,57537: [Backport #13191]

    pty/shl.rb: update [ci skip]

    * sample/pty/shl.rb: stop writer loop when the child exited.
      PTY::ChildExited no longer raises asynchronously since r20298.
      [ruby-dev:49974] [Bug #13191]
    pty/shl.rb: update [ci skip]

    * sample/pty/shl.rb: use io/console instead of stty.
      [ruby-dev:49974] [Bug #13191]
    pty/shl.rb: update [ci skip]

    * sample/pty/shl.rb: do not manage array length separately.
      [ruby-dev:49974] [Bug #13191]
    pty/shl.rb: update [ci skip]

    * sample/pty/shl.rb: leap exited child process.
      [ruby-dev:49974] [Bug #13191]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@58516 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 58516
Added by usa (Usaku NAKAMURA) over 2 years ago

merge revision(s) 57531,57532,57533,57537: [Backport #13191]

pty/shl.rb: update [ci skip]

* sample/pty/shl.rb: stop writer loop when the child exited.
  PTY::ChildExited no longer raises asynchronously since r20298.
  [ruby-dev:49974] [Bug #13191]
pty/shl.rb: update [ci skip]

* sample/pty/shl.rb: use io/console instead of stty.
  [ruby-dev:49974] [Bug #13191]
pty/shl.rb: update [ci skip]

* sample/pty/shl.rb: do not manage array length separately.
  [ruby-dev:49974] [Bug #13191]
pty/shl.rb: update [ci skip]

* sample/pty/shl.rb: leap exited child process.
  [ruby-dev:49974] [Bug #13191]

Revision 881bee60
Added by nagachika (Tomoyuki Chikanaga) over 2 years ago

merge revision(s) 57531,57532,57533,57537: [Backport #13191]

    pty/shl.rb: update [ci skip]

    * sample/pty/shl.rb: stop writer loop when the child exited.
      PTY::ChildExited no longer raises asynchronously since r20298.
      [ruby-dev:49974] [Bug #13191]
    pty/shl.rb: update [ci skip]

    * sample/pty/shl.rb: use io/console instead of stty.
      [ruby-dev:49974] [Bug #13191]
    pty/shl.rb: update [ci skip]

    * sample/pty/shl.rb: do not manage array length separately.
      [ruby-dev:49974] [Bug #13191]
    pty/shl.rb: update [ci skip]

    * sample/pty/shl.rb: leap exited child process.
      [ruby-dev:49974] [Bug #13191]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@58620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 58620
Added by nagachika (Tomoyuki Chikanaga) over 2 years ago

merge revision(s) 57531,57532,57533,57537: [Backport #13191]

pty/shl.rb: update [ci skip]

* sample/pty/shl.rb: stop writer loop when the child exited.
  PTY::ChildExited no longer raises asynchronously since r20298.
  [ruby-dev:49974] [Bug #13191]
pty/shl.rb: update [ci skip]

* sample/pty/shl.rb: use io/console instead of stty.
  [ruby-dev:49974] [Bug #13191]
pty/shl.rb: update [ci skip]

* sample/pty/shl.rb: do not manage array length separately.
  [ruby-dev:49974] [Bug #13191]
pty/shl.rb: update [ci skip]

* sample/pty/shl.rb: leap exited child process.
  [ruby-dev:49974] [Bug #13191]

Revision 188ae0db
Added by usa (Usaku NAKAMURA) over 2 years ago

merge revision(s) 57530: [Backport #13191]

    sample/pty/shl.rb: update sample

    * Specify frozen_string_literal: true.
    * Fix TypeError of raise.
    * Use a character literal instead of Integer.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@59228 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 59228
Added by usa (Usaku NAKAMURA) over 2 years ago

merge revision(s) 57530: [Backport #13191]

sample/pty/shl.rb: update sample

* Specify frozen_string_literal: true.
* Fix TypeError of raise.
* Use a character literal instead of Integer.

Revision fffc133d
Added by nagachika (Tomoyuki Chikanaga) about 2 years ago

merge revision(s) 57530: [Backport #13191]

    sample/pty/shl.rb: update sample

    * Specify frozen_string_literal: true.
    * Fix TypeError of raise.
    * Use a character literal instead of Integer.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@59404 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 59404
Added by nagachika (Tomoyuki Chikanaga) about 2 years ago

merge revision(s) 57530: [Backport #13191]

sample/pty/shl.rb: update sample

* Specify frozen_string_literal: true.
* Fix TypeError of raise.
* Use a character literal instead of Integer.

History

#1

Updated by nobu (Nobuyoshi Nakada) over 2 years ago

  • Status changed from Open to Closed

Applied in changeset r57531.


pty/shl.rb: update [ci skip]

  • sample/pty/shl.rb: stop writer loop when the child exited. PTY::ChildExited no longer raises asynchronously since r20298. [ruby-dev:49974] [Bug #13191]
#2

Updated by usa (Usaku NAKAMURA) over 2 years ago

  • Backport changed from 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN to 2.2: REQUIRED, 2.3: REQUIRED, 2.4: REQUIRED

Updated by usa (Usaku NAKAMURA) over 2 years ago

  • Backport changed from 2.2: REQUIRED, 2.3: REQUIRED, 2.4: REQUIRED to 2.2: REQUIRED, 2.3: DONE, 2.4: REQUIRED

ruby_2_3 r58516 merged revision(s) 57531,57532,57533,57537.

Updated by nagachika (Tomoyuki Chikanaga) over 2 years ago

  • Backport changed from 2.2: REQUIRED, 2.3: DONE, 2.4: REQUIRED to 2.2: REQUIRED, 2.3: DONE, 2.4: DONE

ruby_2_4 r58620 merged revision(s) 57531,57532,57533,57537.

Updated by znz (Kazuhiro NISHIYAMA) over 2 years ago

ruby 2.4.2p131 (2017-05-10 revision 58637) [x86_64-linux] で試してみたところ、 r57530 も backport しないと C-z がきかないようです。

exit したときに shl.rb のプロンプトに戻ってこないので trunk で試してみたら同じ状態でした。
具体的には以下のように exit の後、操作が効かなくなるので C-z で止めて、再度 0 で選ぶと ThreadError になって shl.rb が終了します。

% ruby -v
ruby 2.5.0dev (2017-05-20 trunk 58810) [x86_64-linux]
% ruby sample/pty/shl.rb
>> p
>> c
% (一度戻って確認のためC-z)>> p
0
>> 0
(プロンプト再表示のためEnter)
% exit
% exit
(操作が効かないのでC-z)>> p
0
>> 0
Traceback (most recent call last):
        1: from sample/pty/shl.rb:86:in `<main>'
sample/pty/shl.rb:86:in `run': killed thread (ThreadError)
#6

Updated by znz (Kazuhiro NISHIYAMA) over 2 years ago

  • Status changed from Closed to Open

Updated by nagachika (Tomoyuki Chikanaga) over 2 years ago

  • Backport changed from 2.2: REQUIRED, 2.3: DONE, 2.4: DONE to 2.2: REQUIRED, 2.3: REQUIRED, 2.4: REQUIRED
  • Status changed from Open to Closed

r57530 の backport のため Backport 欄を REQUIRED に戻します。

Updated by usa (Usaku NAKAMURA) over 2 years ago

  • Backport changed from 2.2: REQUIRED, 2.3: REQUIRED, 2.4: REQUIRED to 2.2: REQUIRED, 2.3: DONE, 2.4: REQUIRED

ruby_2_3 r59228 merged revision(s) 57530.

Updated by nagachika (Tomoyuki Chikanaga) about 2 years ago

  • Backport changed from 2.2: REQUIRED, 2.3: DONE, 2.4: REQUIRED to 2.2: REQUIRED, 2.3: DONE, 2.4: DONE

ruby_2_4 r59404 merged revision(s) 57530.

Also available in: Atom PDF