diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-06-08 14:46:23 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-06-08 14:46:23 +0000 |
commit | 795c5f9b40e9b7ad35368a6a86c9c310a6c9a2d8 (patch) | |
tree | 6e2918b083ca5deb96d0620b933538eb89ee5596 | |
parent | ba1c1786d625a9477f029e153a5f10a7e9476319 (diff) | |
download | ruby-795c5f9b40e9b7ad35368a6a86c9c310a6c9a2d8.tar.gz |
* process.c: don't check the availability of FD_CLOEXEC. It should
be available if fork() is available.
* io.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35966 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | io.c | 4 | ||||
-rw-r--r-- | process.c | 14 |
3 files changed, 7 insertions, 18 deletions
@@ -1,3 +1,10 @@ +Fri Jun 8 23:44:14 2012 Tanaka Akira <akr@fsij.org> + + * 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@fsij.org> * process.c (rb_fork_err): revert r35955. The condition needs !chfunc @@ -5444,14 +5444,10 @@ rb_close_before_exec(int lowfd, int maxhint, VALUE noclose_fds) 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) @@ -2650,7 +2650,6 @@ rb_exec_atfork(void* arg, char *errmsg, size_t errmsg_buflen) #endif #ifdef HAVE_FORK -#ifdef FD_CLOEXEC #if SIZEOF_INT == SIZEOF_LONG #define proc_syswait (VALUE (*)(VALUE))rb_syswait #else @@ -2661,7 +2660,6 @@ proc_syswait(VALUE pid) return Qnil; } #endif -#endif static int move_fds_to_avoid_crash(int *fdp, int n, VALUE fds) @@ -2755,10 +2753,8 @@ rb_fork_err(int *status, int (*chfunc)(void*, char *, size_t), void *charg, VALU { 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 @@ rb_fork_err(int *status, int (*chfunc)(void*, char *, size_t), void *charg, VALU ) prefork(); -#ifdef FD_CLOEXEC if (chfunc) { if (status) *status = 0; if (pipe_nocrash(ep, fds)) return -1; @@ -2775,7 +2770,6 @@ rb_fork_err(int *status, int (*chfunc)(void*, char *, size_t), void *charg, VALU return -1; } } -#endif for (; before_fork(), (pid = fork()) < 0; prefork()) { after_fork(); switch (errno) { @@ -2799,11 +2793,9 @@ rb_fork_err(int *status, int (*chfunc)(void*, char *, size_t), void *charg, VALU } /* 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 @@ rb_fork_err(int *status, int (*chfunc)(void*, char *, size_t), void *charg, VALU 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 @@ rb_fork_err(int *status, int (*chfunc)(void*, char *, size_t), void *charg, VALU err = errno; } if (!NIL_P(io)) rb_io_close(io); -#endif #if EXIT_SUCCESS == 127 _exit(EXIT_FAILURE); #else @@ -2845,7 +2833,6 @@ rb_fork_err(int *status, int (*chfunc)(void*, char *, size_t), void *charg, VALU } } after_fork(); -#ifdef FD_CLOEXEC if (pid && chfunc) { ssize_t size; VALUE exc = Qnil; @@ -2884,7 +2871,6 @@ rb_fork_err(int *status, int (*chfunc)(void*, char *, size_t), void *charg, VALU return -1; } } -#endif return pid; } |