From cd6d919373f2d0a1631b10a666d892365407821c Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 5 Feb 2017 01:26:27 +0000 Subject: 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 --- sample/pty/shl.rb | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'sample') diff --git a/sample/pty/shl.rb b/sample/pty/shl.rb index 2360d8dc4c..980748e8f5 100644 --- a/sample/pty/shl.rb +++ b/sample/pty/shl.rb @@ -61,14 +61,11 @@ $reader = Thread.new { while true print ">> " STDOUT.flush + n = nil case gets when /^c/i $shells << PTY.spawn("/bin/csh") - $r_pty,$w_pty = $shells[-1] - $reader.run - if writer == 'Exit' - $shells.pop - end + n = -1 when /^p/i $shells.each_with_index do |s, i| if s @@ -79,15 +76,18 @@ while true 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 - $shells.pop until $shells.empty? or $shells[-1] - 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 -- cgit v1.2.3