summaryrefslogtreecommitdiff
path: root/process.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-20 22:11:56 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-20 22:11:56 +0000
commitfdcac09849a7644618a202215a2615f1f029b48b (patch)
tree8f159f32393bbf032ed13c72c857587981e66568 /process.c
parentea6044ea364bbf5a89ee203182f1b093f20c51b3 (diff)
* backport r32579, r32581, r32587 by akr and r32588 by kazu.
r32579: * io.c (rb_update_max_fd): new function. * internal.h (rb_update_max_fd): declare rb_update_max_fd. * thread_pthread.c (rb_thread_create_timer_thread): update max fd when timer thread pipe is created. r32581: * io.c (UPDATE_MAXFD): removed. r32587: * include/ruby/intern.h (rb_update_max_fd): declaration moved from internal.h. * file.c: ditto. * io.c: call rb_update_max_fd for each new fds. * process.c: ditto. * random.c: ditto. * ruby.c: ditto. * ext/io/console/console.c: ditto. * ext/openssl/ossl_bio.c: ditto. * ext/pty/pty.c: ditto. * ext/socket/init.c: ditto. * ext/socket/socket.c: ditto. * ext/socket/ancdata.c: ditto. * ext/socket/unixsocket.c: ditto. r32588: * io.c (rb_update_max_fd): remove parentheses. they are not in macro. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@32591 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r--process.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/process.c b/process.c
index 1289db53e4..3b8fda313f 100644
--- a/process.c
+++ b/process.c
@@ -1961,6 +1961,7 @@ save_redirect_fd(int fd, VALUE save, char *errmsg, size_t errmsg_buflen)
ERRMSG("dup");
return -1;
}
+ rb_update_max_fd(save_fd);
newary = rb_ary_entry(save, EXEC_OPTION_DUP2);
if (NIL_P(newary)) {
newary = hide_obj(rb_ary_new());
@@ -2077,6 +2078,7 @@ run_exec_dup2(VALUE ary, VALUE save, char *errmsg, size_t errmsg_buflen)
ERRMSG("dup2");
goto fail;
}
+ rb_update_max_fd(pairs[j].newfd);
pairs[j].oldfd = -1;
j = pairs[j].older_index;
if (j != -1)
@@ -2115,6 +2117,7 @@ run_exec_dup2(VALUE ary, VALUE save, char *errmsg, size_t errmsg_buflen)
ERRMSG("dup");
goto fail;
}
+ rb_update_max_fd(extra_fd);
}
else {
ret = redirect_dup2(pairs[i].oldfd, extra_fd);
@@ -2122,6 +2125,7 @@ run_exec_dup2(VALUE ary, VALUE save, char *errmsg, size_t errmsg_buflen)
ERRMSG("dup2");
goto fail;
}
+ rb_update_max_fd(extra_fd);
}
pairs[i].oldfd = extra_fd;
j = pairs[i].older_index;
@@ -2132,6 +2136,7 @@ run_exec_dup2(VALUE ary, VALUE save, char *errmsg, size_t errmsg_buflen)
ERRMSG("dup2");
goto fail;
}
+ rb_update_max_fd(ret);
pairs[j].oldfd = -1;
j = pairs[j].older_index;
}
@@ -2189,6 +2194,7 @@ run_exec_open(VALUE ary, VALUE save, char *errmsg, size_t errmsg_buflen)
ERRMSG("open");
return -1;
}
+ rb_update_max_fd(fd2);
while (i < RARRAY_LEN(ary) &&
(elt = RARRAY_PTR(ary)[i], RARRAY_PTR(elt)[1] == param)) {
fd = FIX2INT(RARRAY_PTR(elt)[0]);
@@ -2203,6 +2209,7 @@ run_exec_open(VALUE ary, VALUE save, char *errmsg, size_t errmsg_buflen)
ERRMSG("dup2");
return -1;
}
+ rb_update_max_fd(fd);
}
i++;
}
@@ -2235,6 +2242,7 @@ run_exec_dup2_child(VALUE ary, VALUE save, char *errmsg, size_t errmsg_buflen)
ERRMSG("dup2");
return -1;
}
+ rb_update_max_fd(newfd);
}
return 0;
}
@@ -2501,6 +2509,7 @@ move_fds_to_avoid_crash(int *fdp, int n, VALUE fds)
ret = fcntl(fdp[i], F_DUPFD, min);
if (ret == -1)
return -1;
+ rb_update_max_fd(ret);
close(fdp[i]);
fdp[i] = ret;
}
@@ -3583,6 +3592,7 @@ ruby_setsid(void)
if (ret == -1) return -1;
if ((fd = open("/dev/tty", O_RDWR)) >= 0) {
+ rb_update_max_fd(fd);
ioctl(fd, TIOCNOTTY, NULL);
close(fd);
}
@@ -4873,6 +4883,7 @@ rb_daemon(int nochdir, int noclose)
err = chdir("/");
if (!noclose && (n = open("/dev/null", O_RDWR, 0)) != -1) {
+ rb_update_max_fd(n);
(void)dup2(n, 0);
(void)dup2(n, 1);
(void)dup2(n, 2);