summaryrefslogtreecommitdiff
path: root/process.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-20 13:26:10 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-20 13:26:10 +0000
commitb41ccc4a9c4d4900e79642bb98ad87b2ba63e766 (patch)
tree39f42db7feb39f86e952030c29de292d295f8a3b /process.c
parent13f62a384b48a5e8ade2319e102a6aa31a0321c9 (diff)
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32587 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 5abdb65e34..b565337b98 100644
--- a/process.c
+++ b/process.c
@@ -1950,6 +1950,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());
@@ -2066,6 +2067,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)
@@ -2104,6 +2106,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);
@@ -2111,6 +2114,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;
@@ -2121,6 +2125,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;
}
@@ -2178,6 +2183,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]);
@@ -2192,6 +2198,7 @@ run_exec_open(VALUE ary, VALUE save, char *errmsg, size_t errmsg_buflen)
ERRMSG("dup2");
return -1;
}
+ rb_update_max_fd(fd);
}
i++;
}
@@ -2224,6 +2231,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;
}
@@ -2490,6 +2498,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;
}
@@ -3538,6 +3547,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);
}
@@ -4828,6 +4838,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);