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

ruby-changes:23915

From: akr <ko1@a...>
Date: Fri, 8 Jun 2012 23:46:33 +0900 (JST)
Subject: [ruby-changes:23915] akr:r35966 (trunk): * process.c: don't check the availability of FD_CLOEXEC. It should

akr	2012-06-08 23:46:23 +0900 (Fri, 08 Jun 2012)

  New Revision: 35966

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

  Log:
    * process.c: don't check the availability of FD_CLOEXEC.  It should
      be available if fork() is available.
    
    * io.c: ditto.

  Modified files:
    trunk/ChangeLog
    trunk/io.c
    trunk/process.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 35965)
+++ ChangeLog	(revision 35966)
@@ -1,3 +1,10 @@
+Fri Jun  8 23:44:14 2012  Tanaka Akira  <akr@f...>
+
+	* process.c: don't check the availability of FD_CLOEXEC.  It should
+	  be available if fork() is available.
+
+	* io.c: ditto.
+
 Fri Jun  8 22:39:32 2012  Tanaka Akira  <akr@f...>
 
 	* process.c (rb_fork_err): revert r35955.  The condition needs !chfunc
Index: io.c
===================================================================
--- io.c	(revision 35965)
+++ io.c	(revision 35966)
@@ -5444,14 +5444,10 @@
         if (!NIL_P(noclose_fds) &&
             RTEST(rb_hash_lookup(noclose_fds, INT2FIX(fd)))) /* async-signal-safe */
             continue;
-#ifdef FD_CLOEXEC
 	ret = fcntl(fd, F_GETFD); /* async-signal-safe */
 	if (ret != -1 && !(ret & FD_CLOEXEC)) {
             fcntl(fd, F_SETFD, ret|FD_CLOEXEC); /* async-signal-safe */
         }
-#else
-	ret = close(fd); /* async-signal-safe */
-#endif
 #define CONTIGUOUS_CLOSED_FDS 20
         if (ret != -1) {
 	    if (max < fd + CONTIGUOUS_CLOSED_FDS)
Index: process.c
===================================================================
--- process.c	(revision 35965)
+++ process.c	(revision 35966)
@@ -2650,7 +2650,6 @@
 #endif
 
 #ifdef HAVE_FORK
-#ifdef FD_CLOEXEC
 #if SIZEOF_INT == SIZEOF_LONG
 #define proc_syswait (VALUE (*)(VALUE))rb_syswait
 #else
@@ -2661,7 +2660,6 @@
     return Qnil;
 }
 #endif
-#endif
 
 static int
 move_fds_to_avoid_crash(int *fdp, int n, VALUE fds)
@@ -2755,10 +2753,8 @@
 {
     rb_pid_t pid;
     int err, state = 0;
-#ifdef FD_CLOEXEC
     int ep[2];
     VALUE io = Qnil;
-#endif
 
 #define prefork() (		\
 	rb_io_flush(rb_stdout), \
@@ -2766,7 +2762,6 @@
 	)
     prefork();
 
-#ifdef FD_CLOEXEC
     if (chfunc) {
 	if (status) *status = 0;
 	if (pipe_nocrash(ep, fds)) return -1;
@@ -2775,7 +2770,6 @@
 	    return -1;
 	}
     }
-#endif
     for (; before_fork(), (pid = fork()) < 0; prefork()) {
 	after_fork();
 	switch (errno) {
@@ -2799,11 +2793,9 @@
 	    }
             /* fall through */
 	  default:
-#ifdef FD_CLOEXEC
 	    if (chfunc) {
 		preserving_errno((close(ep[0]), close(ep[1])));
 	    }
-#endif
 	    if (state && !status) rb_jump_tag(state);
 	    return -1;
 	}
@@ -2816,11 +2808,8 @@
 	    arg.arg = charg;
 	    arg.errmsg = errmsg;
 	    arg.buflen = errmsg_buflen;
-#ifdef FD_CLOEXEC
 	    close(ep[0]);
-#endif
 	    if (!(int)rb_protect(chfunc_protect, (VALUE)&arg, &state)) _exit(EXIT_SUCCESS);
-#ifdef FD_CLOEXEC
 	    if (write(ep[1], &state, sizeof(state)) == sizeof(state) && state) {
 		VALUE errinfo = rb_errinfo();
 		io = rb_io_fdopen(ep[1], O_WRONLY|O_BINARY, NULL);
@@ -2836,7 +2825,6 @@
 		    err = errno;
             }
 	    if (!NIL_P(io)) rb_io_close(io);
-#endif
 #if EXIT_SUCCESS == 127
 	    _exit(EXIT_FAILURE);
 #else
@@ -2845,7 +2833,6 @@
 	}
     }
     after_fork();
-#ifdef FD_CLOEXEC
     if (pid && chfunc) {
 	ssize_t size;
 	VALUE exc = Qnil;
@@ -2884,7 +2871,6 @@
 	    return -1;
 	}
     }
-#endif
     return pid;
 }
 

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

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