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

ruby-changes:17170

From: nobu <ko1@a...>
Date: Fri, 3 Sep 2010 06:14:58 +0900 (JST)
Subject: [ruby-changes:17170] Ruby:r29169 (trunk): * ext/pty/pty.c (chfunc): restore errno from SystemCallError and

nobu	2010-09-03 06:14:51 +0900 (Fri, 03 Sep 2010)

  New Revision: 29169

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

  Log:
    * ext/pty/pty.c (chfunc): restore errno from SystemCallError and
      propagate proper exception to the parent.  [ruby-dev:41965]

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

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 29168)
+++ ChangeLog	(revision 29169)
@@ -1,3 +1,8 @@
+Fri Sep  3 06:14:40 2010  Nobuyoshi Nakada  <nobu@r...>
+
+	* ext/pty/pty.c (chfunc): restore errno from SystemCallError and
+	  propagate proper exception to the parent.  [ruby-dev:41965]
+
 Thu Sep  2 22:10:38 2010  Tanaka Akira  <akr@f...>
 
 	* ext/pathname/pathname.c (path_file_p): Pathname#file?
Index: ext/pty/pty.c
===================================================================
--- ext/pty/pty.c	(revision 29168)
+++ ext/pty/pty.c	(revision 29169)
@@ -162,6 +162,7 @@
     int slave = carg->slave;
     int argc = carg->argc;
     VALUE *argv = carg->argv;
+    VALUE exc;
 
     struct exec_info arg;
     int status;
@@ -221,7 +222,12 @@
     arg.argv = argv;
     rb_protect(pty_exec, (VALUE)&arg, &status);
     sleep(1);
-    return -1;
+    errno = ENOENT;		/* last resort */
+    exc = rb_errinfo();
+    if (!NIL_P(exc)) {
+	errno = NUM2INT(rb_attr_get(exc, rb_intern("errno")));
+    }
+    ERROR_EXIT(StringValueCStr(argv[0]));
 #undef ERROR_EXIT
 }
 
Index: version.h
===================================================================
--- version.h	(revision 29168)
+++ version.h	(revision 29169)
@@ -1,11 +1,11 @@
 #define RUBY_VERSION "1.9.3"
-#define RUBY_RELEASE_DATE "2010-09-02"
+#define RUBY_RELEASE_DATE "2010-09-03"
 #define RUBY_PATCHLEVEL -1
 #define RUBY_BRANCH_NAME "trunk"
 
 #define RUBY_RELEASE_YEAR 2010
 #define RUBY_RELEASE_MONTH 9
-#define RUBY_RELEASE_DAY 2
+#define RUBY_RELEASE_DAY 3
 
 #include "ruby/version.h"
 
Index: test/test_pty.rb
===================================================================
--- test/test_pty.rb	(revision 29168)
+++ test/test_pty.rb	(revision 29169)
@@ -1,6 +1,7 @@
 require 'test/unit'
 require_relative 'ruby/envutil'
 require 'shellwords'
+require 'tmpdir'
 
 begin
   require 'pty'
@@ -123,5 +124,12 @@
       ) { master.readpartial(10) }
     }
   end
+
+  def test_getpty_nonexistent
+    bug3672 = '[ruby-dev:41965]'
+    Dir.mktmpdir do |tmpdir|
+      assert_raise(Errno::ENOENT, bug3672) {PTY.getpty(File.join(tmpdir, "no-such-command"))}
+    end
+  end
 end if defined? PTY
 

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

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