summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/io/console/console.c4
-rw-r--r--ext/openssl/ossl_bio.c2
-rw-r--r--ext/pty/pty.c26
-rw-r--r--ext/socket/ancdata.c4
-rw-r--r--ext/socket/init.c6
-rw-r--r--ext/socket/socket.c4
-rw-r--r--ext/socket/unixsocket.c2
7 files changed, 24 insertions, 24 deletions
diff --git a/ext/io/console/console.c b/ext/io/console/console.c
index e7983bbcb9a..72f507210cb 100644
--- a/ext/io/console/console.c
+++ b/ext/io/console/console.c
@@ -564,7 +564,7 @@ console_dev(VALUE klass)
#ifdef CONSOLE_DEVICE_FOR_WRITING
fd = open(CONSOLE_DEVICE_FOR_WRITING, O_WRONLY);
if (fd < 0) return Qnil;
- rb_update_max_fd(fd);
+ rb_fd_set_cloexec(fd);
args[1] = INT2FIX(O_WRONLY);
args[0] = INT2NUM(fd);
out = rb_class_new_instance(2, args, klass);
@@ -576,7 +576,7 @@ console_dev(VALUE klass)
#endif
return Qnil;
}
- rb_update_max_fd(fd);
+ rb_fd_set_cloexec(fd);
args[1] = INT2FIX(O_RDWR);
args[0] = INT2NUM(fd);
con = rb_class_new_instance(2, args, klass);
diff --git a/ext/openssl/ossl_bio.c b/ext/openssl/ossl_bio.c
index ed7c0a71a5d..da63c722e54 100644
--- a/ext/openssl/ossl_bio.c
+++ b/ext/openssl/ossl_bio.c
@@ -28,7 +28,7 @@ ossl_obj2bio(VALUE obj)
if ((fd = dup(FPTR_TO_FD(fptr))) < 0){
rb_sys_fail(0);
}
- rb_update_max_fd(fd);
+ rb_fd_set_cloexec(fd);
if (!(fp = fdopen(fd, "r"))){
close(fd);
rb_sys_fail(0);
diff --git a/ext/pty/pty.c b/ext/pty/pty.c
index b18eb68f776..8a6994dea04 100644
--- a/ext/pty/pty.c
+++ b/ext/pty/pty.c
@@ -177,7 +177,7 @@ chfunc(void *data, char *errbuf, size_t errbuf_len)
{
int i = open("/dev/tty", O_RDONLY);
if (i < 0) ERROR_EXIT("/dev/tty");
- rb_update_max_fd(i);
+ rb_fd_set_cloexec(i);
if (ioctl(i, TIOCNOTTY, (char *)0))
ERROR_EXIT("ioctl(TIOCNOTTY)");
close(i);
@@ -199,7 +199,7 @@ chfunc(void *data, char *errbuf, size_t errbuf_len)
if (slave < 0) {
ERROR_EXIT("open: pty slave");
}
- rb_update_max_fd(slave);
+ rb_fd_set_cloexec(slave);
close(master);
#endif
dup2(slave,0);
@@ -291,7 +291,7 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg,
sigemptyset(&dfl.sa_mask);
if ((masterfd = posix_openpt(O_RDWR|O_NOCTTY)) == -1) goto error;
- rb_update_max_fd(masterfd);
+ rb_fd_set_cloexec(masterfd);
if (sigaction(SIGCHLD, &dfl, &old) == -1) goto error;
if (grantpt(masterfd) == -1) goto grantpt_error;
if (sigaction(SIGCHLD, &old, NULL) == -1) goto error;
@@ -299,7 +299,7 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg,
if ((slavedevice = ptsname(masterfd)) == NULL) goto error;
if (no_mesg(slavedevice, nomesg) == -1) goto error;
if ((slavefd = open(slavedevice, O_RDWR|O_NOCTTY, 0)) == -1) goto error;
- rb_update_max_fd(slavefd);
+ rb_fd_set_cloexec(slavefd);
#if defined I_PUSH && !defined linux
if (ioctl(slavefd, I_PUSH, "ptem") == -1) goto error;
@@ -331,8 +331,8 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg,
if (!fail) return -1;
rb_raise(rb_eRuntimeError, "openpty() failed");
}
- rb_update_max_fd(*master);
- rb_update_max_fd(*slave);
+ rb_fd_set_cloexec(*master);
+ rb_fd_set_cloexec(*slave);
if (no_mesg(SlaveName, nomesg) == -1) {
if (!fail) return -1;
rb_raise(rb_eRuntimeError, "can't chmod slave pty");
@@ -348,11 +348,11 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg,
if (!fail) return -1;
rb_raise(rb_eRuntimeError, "_getpty() failed");
}
- rb_update_max_fd(*master);
+ rb_fd_set_cloexec(*master);
*slave = open(name, O_RDWR);
/* error check? */
- rb_update_max_fd(*slave);
+ rb_fd_set_cloexec(*slave);
strlcpy(SlaveName, name, DEVICELEN);
return 0;
@@ -366,7 +366,7 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg,
extern int grantpt(int);
if((masterfd = open("/dev/ptmx", O_RDWR, 0)) == -1) goto error;
- rb_update_max_fd(masterfd);
+ rb_fd_set_cloexec(masterfd);
s = signal(SIGCHLD, SIG_DFL);
if(grantpt(masterfd) == -1) goto error;
signal(SIGCHLD, s);
@@ -374,7 +374,7 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg,
if((slavedevice = ptsname(masterfd)) == NULL) goto error;
if (no_mesg(slavedevice, nomesg) == -1) goto error;
if((slavefd = open(slavedevice, O_RDWR, 0)) == -1) goto error;
- rb_update_max_fd(slavefd);
+ rb_fd_set_cloexec(slavefd);
#if defined I_PUSH && !defined linux
if(ioctl(slavefd, I_PUSH, "ptem") == -1) goto error;
if(ioctl(slavefd, I_PUSH, "ldterm") == -1) goto error;
@@ -398,11 +398,11 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg,
for (p = deviceNo; *p != NULL; p++) {
snprintf(MasterName, sizeof MasterName, MasterDevice, *p);
if ((masterfd = open(MasterName,O_RDWR,0)) >= 0) {
- rb_update_max_fd(masterfd);
+ rb_fd_set_cloexec(masterfd);
*master = masterfd;
snprintf(SlaveName, DEVICELEN, SlaveDevice, *p);
if ((slavefd = open(SlaveName,O_RDWR,0)) >= 0) {
- rb_update_max_fd(slavefd);
+ rb_fd_set_cloexec(slavefd);
*slave = slavefd;
if (chown(SlaveName, getuid(), getgid()) != 0) goto error;
if (chmod(SlaveName, nomesg ? 0600 : 0622) != 0) goto error;
@@ -590,7 +590,7 @@ pty_getpty(int argc, VALUE *argv, VALUE self)
wfptr->fd = dup(info.fd);
if (wfptr->fd == -1)
rb_sys_fail("dup()");
- rb_update_max_fd(wfptr->fd);
+ rb_fd_set_cloexec(wfptr->fd);
wfptr->pathv = rfptr->pathv;
res = rb_ary_new2(3);
diff --git a/ext/socket/ancdata.c b/ext/socket/ancdata.c
index 9db4426a804..848b332181c 100644
--- a/ext/socket/ancdata.c
+++ b/ext/socket/ancdata.c
@@ -1396,7 +1396,7 @@ discard_cmsg(struct cmsghdr *cmh, char *msg_end, int msg_peek_p)
int *end = (int *)((char *)cmh + cmh->cmsg_len);
while ((char *)fdp + sizeof(int) <= (char *)end &&
(char *)fdp + sizeof(int) <= msg_end) {
- rb_update_max_fd(*fdp);
+ rb_fd_set_cloexec(*fdp);
close(*fdp);
fdp++;
}
@@ -1439,7 +1439,7 @@ make_io_for_unix_rights(VALUE ctl, struct cmsghdr *cmh, char *msg_end)
VALUE io;
if (fstat(fd, &stbuf) == -1)
rb_raise(rb_eSocket, "invalid fd in SCM_RIGHTS");
- rb_update_max_fd(fd);
+ rb_fd_set_cloexec(fd);
if (S_ISSOCK(stbuf.st_mode))
io = rsock_init_sock(rb_obj_alloc(rb_cSocket), fd);
else
diff --git a/ext/socket/init.c b/ext/socket/init.c
index 0a2365850fa..ca271f3b5a5 100644
--- a/ext/socket/init.c
+++ b/ext/socket/init.c
@@ -252,7 +252,7 @@ rsock_socket(int domain, int type, int proto)
}
}
if (0 <= fd)
- rb_update_max_fd(fd);
+ rb_fd_set_cloexec(fd);
return fd;
}
@@ -466,7 +466,7 @@ rsock_s_accept_nonblock(VALUE klass, rb_io_t *fptr, struct sockaddr *sockaddr, s
}
rb_sys_fail("accept(2)");
}
- rb_update_max_fd(fd2);
+ rb_fd_set_cloexec(fd2);
make_fd_nonblock(fd2);
return rsock_init_sock(rb_obj_alloc(klass), fd2);
}
@@ -513,7 +513,7 @@ rsock_s_accept(VALUE klass, int fd, struct sockaddr *sockaddr, socklen_t *len)
}
rb_sys_fail(0);
}
- rb_update_max_fd(fd2);
+ rb_fd_set_cloexec(fd2);
if (!klass) return INT2NUM(fd2);
return rsock_init_sock(rb_obj_alloc(klass), fd2);
}
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 4613892e7d8..92407185fc2 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -119,8 +119,8 @@ rsock_sock_s_socketpair(int argc, VALUE *argv, VALUE klass)
if (ret < 0) {
rb_sys_fail("socketpair(2)");
}
- rb_update_max_fd(sp[0]);
- rb_update_max_fd(sp[1]);
+ rb_fd_set_cloexec(sp[0]);
+ rb_fd_set_cloexec(sp[1]);
s1 = rsock_init_sock(rb_obj_alloc(klass), sp[0]);
s2 = rsock_init_sock(rb_obj_alloc(klass), sp[1]);
diff --git a/ext/socket/unixsocket.c b/ext/socket/unixsocket.c
index 15196e7b1f6..7f2d6281671 100644
--- a/ext/socket/unixsocket.c
+++ b/ext/socket/unixsocket.c
@@ -383,7 +383,7 @@ unix_recv_io(int argc, VALUE *argv, VALUE sock)
#if FD_PASSING_BY_MSG_CONTROL
memcpy(&fd, CMSG_DATA(&cmsg.hdr), sizeof(int));
#endif
- rb_update_max_fd(fd);
+ rb_fd_set_cloexec(fd);
if (klass == Qnil)
return INT2FIX(fd);