summaryrefslogtreecommitdiff
path: root/ext/pty/pty.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 /ext/pty/pty.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 'ext/pty/pty.c')
-rw-r--r--ext/pty/pty.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/ext/pty/pty.c b/ext/pty/pty.c
index 1461d28..3797972 100644
--- a/ext/pty/pty.c
+++ b/ext/pty/pty.c
@@ -177,6 +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);
if (ioctl(i, TIOCNOTTY, (char *)0))
ERROR_EXIT("ioctl(TIOCNOTTY)");
close(i);
@@ -198,6 +199,7 @@ chfunc(void *data, char *errbuf, size_t errbuf_len)
if (slave < 0) {
ERROR_EXIT("open: pty slave");
}
+ rb_update_max_fd(slave);
close(master);
#endif
dup2(slave,0);
@@ -289,6 +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);
if (sigaction(SIGCHLD, &dfl, &old) == -1) goto error;
if (grantpt(masterfd) == -1) goto grantpt_error;
if (sigaction(SIGCHLD, &old, NULL) == -1) goto error;
@@ -296,6 +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);
#if defined I_PUSH && !defined linux
if (ioctl(slavefd, I_PUSH, "ptem") == -1) goto error;
@@ -327,6 +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);
if (no_mesg(SlaveName, nomesg) == -1) {
if (!fail) return -1;
rb_raise(rb_eRuntimeError, "can't chmod slave pty");
@@ -342,8 +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);
*slave = open(name, O_RDWR);
+ /* error check? */
+ rb_update_max_fd(*slave);
strlcpy(SlaveName, name, DEVICELEN);
return 0;
@@ -357,6 +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);
s = signal(SIGCHLD, SIG_DFL);
if(grantpt(masterfd) == -1) goto error;
signal(SIGCHLD, s);
@@ -364,6 +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);
#if defined I_PUSH && !defined linux
if(ioctl(slavefd, I_PUSH, "ptem") == -1) goto error;
if(ioctl(slavefd, I_PUSH, "ldterm") == -1) goto error;
@@ -387,9 +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);
*master = masterfd;
snprintf(SlaveName, DEVICELEN, SlaveDevice, *p);
if ((slavefd = open(SlaveName,O_RDWR,0)) >= 0) {
+ rb_update_max_fd(slavefd);
*slave = slavefd;
if (chown(SlaveName, getuid(), getgid()) != 0) goto error;
if (chmod(SlaveName, nomesg ? 0600 : 0622) != 0) goto error;
@@ -577,6 +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);
wfptr->pathv = rfptr->pathv;
res = rb_ary_new2(3);