ruby-changes:46499
From: nagachika <ko1@a...>
Date: Tue, 9 May 2017 23:11:18 +0900 (JST)
Subject: [ruby-changes:46499] nagachika:r58620 (ruby_2_4): merge revision(s) 57531, 57532, 57533, 57537: [Backport #13191]
nagachika 2017-05-09 23:11:14 +0900 (Tue, 09 May 2017) New Revision: 58620 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58620 Log: 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] Modified directories: branches/ruby_2_4/ Modified files: branches/ruby_2_4/sample/pty/shl.rb branches/ruby_2_4/version.h Index: ruby_2_4/version.h =================================================================== --- ruby_2_4/version.h (revision 58619) +++ ruby_2_4/version.h (revision 58620) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/version.h#L1 #define RUBY_VERSION "2.4.2" #define RUBY_RELEASE_DATE "2017-05-09" -#define RUBY_PATCHLEVEL 115 +#define RUBY_PATCHLEVEL 116 #define RUBY_RELEASE_YEAR 2017 #define RUBY_RELEASE_MONTH 5 Index: ruby_2_4/sample/pty/shl.rb =================================================================== --- ruby_2_4/sample/pty/shl.rb (revision 58619) +++ ruby_2_4/sample/pty/shl.rb (revision 58620) @@ -10,15 +10,15 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/sample/pty/shl.rb#L10 # q quit require 'pty' +require 'io/console' $shells = [] -$n_shells = 0 $r_pty = nil $w_pty = nil def writer - system "stty -echo raw" + STDIN.raw! begin while true c = STDIN.getc @@ -33,16 +33,17 @@ def writer https://github.com/ruby/ruby/blob/trunk/ruby_2_4/sample/pty/shl.rb#L33 $reader.raise(nil) return 'Exit' ensure - system "stty echo -raw" + STDIN.cooked! end end $reader = Thread.new { while true begin - next if $r_pty.nil? + Thread.stop unless $r_pty c = $r_pty.getc if c.nil? then + Thread.main.raise('Exit') Thread.stop end print c.chr @@ -59,19 +60,14 @@ $reader = Thread.new { https://github.com/ruby/ruby/blob/trunk/ruby_2_4/sample/pty/shl.rb#L60 while true print ">> " STDOUT.flush + n = nil case gets when /^c/i - $shells[$n_shells] = PTY.spawn("/bin/csh") - $r_pty,$w_pty = $shells[$n_shells] - $n_shells += 1 - $reader.run - if writer == 'Exit' - $n_shells -= 1 - $shells[$n_shells] = nil - end + $shells << PTY.spawn("/bin/csh") + n = -1 when /^p/i - for i in 0..$n_shells - unless $shells[i].nil? + $shells.each_with_index do |s, i| + if s print i,"\n" end end @@ -79,14 +75,18 @@ while true https://github.com/ruby/ruby/blob/trunk/ruby_2_4/sample/pty/shl.rb#L75 n = $1.to_i if $shells[n].nil? print "\##{i} doesn't exist\n" - else - $r_pty,$w_pty = $shells[n] - $reader.run - if writer == 'Exit' then - $shells[n] = nil - end + n = nil end when /^q/i exit end + if n + $r_pty, $w_pty, pid = $shells[n] + $reader.run + if writer == 'Exit' then + Process.wait(pid) + $shells[n] = nil + $shells.pop until $shells.empty? or $shells[-1] + end + end end Index: ruby_2_4 =================================================================== --- ruby_2_4 (revision 58619) +++ ruby_2_4 (revision 58620) Property changes on: ruby_2_4 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /trunk:r57531-57533,57537 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/