summaryrefslogtreecommitdiff
path: root/process.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-04-25 01:55:22 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-04-25 01:55:22 +0000
commit62da750abea80bad64465791e897bcb4c24d5f9a (patch)
treee7e1c566cb1e645389ba12323902573db8790ba8 /process.c
parent963941b156a38aed362421b6eb6247d1d5c977f0 (diff)
* 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
Diffstat (limited to 'process.c')
-rw-r--r--process.c8
1 files changed, 8 insertions, 0 deletions
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)) {