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

ruby-changes:21508

From: akr <ko1@a...>
Date: Sat, 29 Oct 2011 22:11:25 +0900 (JST)
Subject: [ruby-changes:21508] akr:r33557 (trunk): * include/ruby/intern.h (rb_cloexec_dup2): declared.

akr	2011-10-29 22:11:01 +0900 (Sat, 29 Oct 2011)

  New Revision: 33557

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

  Log:
    * include/ruby/intern.h (rb_cloexec_dup2): declared.
    
    * io.c (rb_cloexec_dup2): new function.
      (io_reopen): use rb_cloexec_dup2.

  Modified files:
    trunk/ChangeLog
    trunk/include/ruby/intern.h
    trunk/io.c

Index: include/ruby/intern.h
===================================================================
--- include/ruby/intern.h	(revision 33556)
+++ include/ruby/intern.h	(revision 33557)
@@ -504,6 +504,7 @@
 int rb_reserved_fd_p(int fd);
 int rb_cloexec_open(const char *pathname, int flags, mode_t mode);
 int rb_cloexec_dup(int oldfd);
+int rb_cloexec_dup2(int oldfd, int newfd);
 #define RB_RESERVED_FD_P(fd) rb_reserved_fd_p(fd)
 void rb_update_max_fd(int fd);
 void rb_fd_set_cloexec(int fd);
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 33556)
+++ ChangeLog	(revision 33557)
@@ -1,3 +1,10 @@
+Sat Oct 29 22:06:37 2011  Tanaka Akira  <akr@f...>
+
+	* include/ruby/intern.h (rb_cloexec_dup2): declared.
+
+	* io.c (rb_cloexec_dup2): new function.
+	  (io_reopen): use rb_cloexec_dup2.
+
 Sat Oct 20 21:08:18 2011  Tajima Akil <artonx@y...>
 
 	* win32/Makefile.sub (CONFIG_H): have stdint.h if VC2010.
Index: io.c
===================================================================
--- io.c	(revision 33556)
+++ io.c	(revision 33557)
@@ -227,6 +227,17 @@
     return ret;
 }
 
+int
+rb_cloexec_dup2(int oldfd, int newfd)
+{
+    int ret;
+
+    ret = dup2(oldfd, newfd);
+    if (ret == -1) return -1;
+    fd_set_cloexec(ret);
+    return ret;
+}
+
 #define argf_of(obj) (*(struct argf *)DATA_PTR(obj))
 #define ARGF argf_of(argf)
 
@@ -5870,17 +5881,17 @@
     if (fd != fd2) {
 	if (IS_PREP_STDIO(fptr) || fd <= 2 || !fptr->stdio_file) {
 	    /* need to keep FILE objects of stdin, stdout and stderr */
-	    if (dup2(fd2, fd) < 0)
+	    if (rb_cloexec_dup2(fd2, fd) < 0)
 		rb_sys_fail_path(orig->pathv);
-            rb_fd_set_cloexec(fd);
+            rb_update_max_fd(fd);
 	}
 	else {
             fclose(fptr->stdio_file);
             fptr->stdio_file = 0;
             fptr->fd = -1;
-            if (dup2(fd2, fd) < 0)
+            if (rb_cloexec_dup2(fd2, fd) < 0)
                 rb_sys_fail_path(orig->pathv);
-            rb_fd_set_cloexec(fd);
+            rb_update_max_fd(fd);
             fptr->fd = fd;
 	}
 	rb_thread_fd_close(fd);

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

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