summaryrefslogtreecommitdiff
path: root/process.c
diff options
context:
space:
mode:
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);