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

ruby-changes:22134

From: kosaki <ko1@a...>
Date: Tue, 3 Jan 2012 10:00:35 +0900 (JST)
Subject: [ruby-changes:22134] kosaki:r34183 (ruby_1_9_3): merge revision(s) 33468:

kosaki	2012-01-03 10:00:23 +0900 (Tue, 03 Jan 2012)

  New Revision: 34183

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=34183

  Log:
    merge revision(s) 33468:
    
    * ext/pty/pty.c (pty_check): should return nil until the child
      terminates or stops.  [ruby-dev:44600] [Bug #2642]

  Modified files:
    branches/ruby_1_9_3/ChangeLog
    branches/ruby_1_9_3/ext/pty/pty.c
    branches/ruby_1_9_3/test/test_pty.rb
    branches/ruby_1_9_3/version.h

Index: ruby_1_9_3/ChangeLog
===================================================================
--- ruby_1_9_3/ChangeLog	(revision 34182)
+++ ruby_1_9_3/ChangeLog	(revision 34183)
@@ -1,3 +1,8 @@
+Mon Jan  2 20:00:01 2012  Nobuyoshi Nakada  <nobu@r...>
+
+	* ext/pty/pty.c (pty_check): should return nil until the child
+	  terminates or stops.  [ruby-dev:44600] [Bug #2642]
+
 Mon Jan  2 19:27:18 2012  Yusuke Endoh  <mame@t...>
 
 	* thread.c (update_coverage): skip coverage count up if the current
Index: ruby_1_9_3/ext/pty/pty.c
===================================================================
--- ruby_1_9_3/ext/pty/pty.c	(revision 34182)
+++ ruby_1_9_3/ext/pty/pty.c	(revision 34183)
@@ -658,7 +658,7 @@
 
     rb_scan_args(argc, argv, "11", &pid, &exc);
     cpid = rb_waitpid(NUM2PIDT(pid), &status, WNOHANG|WUNTRACED);
-    if (cpid == -1) return Qnil;
+    if (cpid == -1 || cpid == 0) return Qnil;
 
     if (!RTEST(exc)) return rb_last_status_get();
     raise_from_check(cpid, status);
Index: ruby_1_9_3/version.h
===================================================================
--- ruby_1_9_3/version.h	(revision 34182)
+++ ruby_1_9_3/version.h	(revision 34183)
@@ -1,10 +1,10 @@
 #define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 9
+#define RUBY_PATCHLEVEL 10
 
-#define RUBY_RELEASE_DATE "2012-01-03"
+#define RUBY_RELEASE_DATE "2012-01-02"
 #define RUBY_RELEASE_YEAR 2012
 #define RUBY_RELEASE_MONTH 1
-#define RUBY_RELEASE_DAY 3
+#define RUBY_RELEASE_DAY 2
 
 #include "ruby/version.h"
 
Index: ruby_1_9_3/test/test_pty.rb
===================================================================
--- ruby_1_9_3/test/test_pty.rb	(revision 34182)
+++ ruby_1_9_3/test/test_pty.rb	(revision 34183)
@@ -163,5 +163,37 @@
       }
     end
   end
+
+  def test_pty_check_default
+    st1 = st2 = pid = nil
+    `echo` # preset $?
+    PTY.spawn("cat") do |r,w,id|
+      pid = id
+      st1 = PTY.check(pid)
+      w.close
+      r.close
+      sleep(0.1)
+      st2 = PTY.check(pid)
+    end
+    assert_equal(pid, st1.pid) if st1
+    assert_nil(st1)
+    assert_equal(pid, st2.pid)
+  end
+
+  def test_pty_check_raise
+    bug2642 = '[ruby-dev:44600]'
+    st1 = st2 = pid = nil
+    PTY.spawn("cat") do |r,w,id|
+      pid = id
+      assert_nothing_raised(PTY::ChildExited, bug2642) {st1 = PTY.check(pid, true)}
+      w.close
+      r.close
+      sleep(0.1)
+      st2 = assert_raise(PTY::ChildExited, bug2642) {PTY.check(pid, true)}.status
+    end
+    assert_equal(pid, st1.pid) if st1
+    assert_nil(st1)
+    assert_equal(pid, st2.pid)
+  end
 end if defined? PTY
 

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

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