1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
nobu 2017-02-05 01:26:27 +00:00
parent a6b9b360ce
commit cd6d919373

View file

@ -61,14 +61,11 @@ $reader = Thread.new {
while true while true
print ">> " print ">> "
STDOUT.flush STDOUT.flush
n = nil
case gets case gets
when /^c/i when /^c/i
$shells << PTY.spawn("/bin/csh") $shells << PTY.spawn("/bin/csh")
$r_pty,$w_pty = $shells[-1] n = -1
$reader.run
if writer == 'Exit'
$shells.pop
end
when /^p/i when /^p/i
$shells.each_with_index do |s, i| $shells.each_with_index do |s, i|
if s if s
@ -79,15 +76,18 @@ while true
n = $1.to_i n = $1.to_i
if $shells[n].nil? if $shells[n].nil?
print "\##{i} doesn't exist\n" print "\##{i} doesn't exist\n"
else n = nil
$r_pty,$w_pty = $shells[n]
$reader.run
if writer == 'Exit' then
$shells[n] = nil
$shells.pop until $shells.empty? or $shells[-1]
end
end end
when /^q/i when /^q/i
exit exit
end 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 end