From 62da750abea80bad64465791e897bcb4c24d5f9a Mon Sep 17 00:00:00 2001 From: usa Date: Fri, 25 Apr 2008 01:55:22 +0000 Subject: [PATCH] * include/ruby/win32.h: define mode_t for umask. * process.c (check_exec_options_i, check_exec_fds, run_exec_options): support "close_others" only when fork(2) is available. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ include/ruby/win32.h | 3 +++ process.c | 8 ++++++++ 3 files changed, 18 insertions(+) diff --git a/ChangeLog b/ChangeLog index cbcdfa32b1..30399973ec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Fri Apr 25 10:52:27 2008 NAKAMURA Usaku + + * include/ruby/win32.h: define mode_t for umask. + + * process.c (check_exec_options_i, check_exec_fds, run_exec_options): + support "close_others" only when fork(2) is available. + Fri Apr 25 00:16:11 2008 Tanaka Akira * process.c: include sys/stat.h for umask. diff --git a/include/ruby/win32.h b/include/ruby/win32.h index 43036b8dc8..4e1f14e9e1 100644 --- a/include/ruby/win32.h +++ b/include/ruby/win32.h @@ -89,6 +89,9 @@ typedef unsigned int uintptr_t; # define _UINTPTR_T_DEFINED # endif #endif +#ifndef __MINGW32__ +# define mode_t int +#endif #ifdef _M_IX86 # define WIN95 1 diff --git a/process.c b/process.c index 8eb474f447..84814bebb6 100644 --- a/process.c +++ b/process.c @@ -1434,6 +1434,7 @@ check_exec_options_i(st_data_t st_key, st_data_t st_val, st_data_t arg) } rb_ary_store(options, EXEC_OPTION_UMASK, LONG2NUM(cmask)); } +#ifdef HAVE_FORK else if (id == rb_intern("close_others")) { if (!NIL_P(rb_ary_entry(options, EXEC_OPTION_CLOSE_OTHERS))) { rb_raise(rb_eArgError, "close_others option specified twice"); @@ -1441,6 +1442,7 @@ check_exec_options_i(st_data_t st_key, st_data_t st_val, st_data_t arg) val = RTEST(val) ? Qtrue : Qfalse; rb_ary_store(options, EXEC_OPTION_CLOSE_OTHERS, val); } +#endif else if (id == rb_intern("in")) { key = INT2FIX(0); goto redirect; @@ -1501,9 +1503,11 @@ check_exec_fds(VALUE options) } } } +#ifdef HAVE_FORK if (RTEST(rb_ary_entry(options, EXEC_OPTION_CLOSE_OTHERS))) { rb_ary_store(options, EXEC_OPTION_CLOSE_OTHERS, INT2FIX(maxhint)); } +#endif return h; } @@ -1843,6 +1847,7 @@ run_exec_dup2(VALUE ary) if (pairs[i].oldfd == -1) continue; if (pairs[i].oldfd == pairs[i].newfd) { /* self cycle */ +#ifdef F_GETFD int fd = pairs[i].oldfd; ret = fcntl(fd, F_GETFD); if (ret == -1) @@ -1853,6 +1858,7 @@ run_exec_dup2(VALUE ary) if (ret == -1) goto fail; } +#endif pairs[i].oldfd = -1; continue; } @@ -2045,10 +2051,12 @@ run_exec_options(const struct rb_exec_arg *e) return -1; } +#ifdef HAVE_FORK obj = rb_ary_entry(options, EXEC_OPTION_CLOSE_OTHERS); if (RTEST(obj)) { rb_close_before_exec(3, FIX2INT(obj), e->redirect_fds); } +#endif obj = rb_ary_entry(options, EXEC_OPTION_OPEN); if (!NIL_P(obj)) {