summaryrefslogtreecommitdiff
path: root/sample/pty
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-02-05 01:26:27 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-02-05 01:26:27 +0000
commitcd6d919373f2d0a1631b10a666d892365407821c (patch)
tree5e890c7a32a61740bf289b4b928a786ef52a9027 /sample/pty
parenta6b9b360ce6874d6545ec26e5b860cb5c0118f00 (diff)
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
Diffstat (limited to 'sample/pty')
-rw-r--r--sample/pty/shl.rb24
1 files changed, 12 insertions, 12 deletions
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