[前][次][番号順一覧][スレッド一覧]

ruby-changes:45464

From: nobu <ko1@a...>
Date: Sun, 5 Feb 2017 10:26:32 +0900 (JST)
Subject: [ruby-changes:45464] nobu:r57537 (trunk): pty/shl.rb: update [ci skip]

nobu	2017-02-05 10:26:27 +0900 (Sun, 05 Feb 2017)

  New Revision: 57537

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57537

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

  Modified files:
    trunk/sample/pty/shl.rb
Index: sample/pty/shl.rb
===================================================================
--- sample/pty/shl.rb	(revision 57536)
+++ sample/pty/shl.rb	(revision 57537)
@@ -61,14 +61,11 @@ $reader = Thread.new { https://github.com/ruby/ruby/blob/trunk/sample/pty/shl.rb#L61
 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 https://github.com/ruby/ruby/blob/trunk/sample/pty/shl.rb#L76
     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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]