diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-10-24 13:40:13 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-10-24 13:40:13 +0000 |
commit | 5153fd2a5e930b70ebae087e2f6e254cf4a30929 (patch) | |
tree | 912cfbf3836662e943c3634b7eecff1cf7c01de3 /ext/pty/pty.c | |
parent | be561cbebedeb3a5c8cf164a488c56ffd412d894 (diff) | |
download | ruby-5153fd2a5e930b70ebae087e2f6e254cf4a30929.tar.gz |
* ext/pty/pty.c (get_device_once): delay rb_fd_set_cloexec() until
grantpt() on Solaris. grantpt() doesn't work with CLOEXEC on
Solaris 10.
reported by Naohisa GOTO. [ruby-dev:44688] [Bug #5475]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33519 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/pty/pty.c')
-rw-r--r-- | ext/pty/pty.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/ext/pty/pty.c b/ext/pty/pty.c index 8a6994dea0..e3ae8fe329 100644 --- a/ext/pty/pty.c +++ b/ext/pty/pty.c @@ -290,10 +290,18 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg, dfl.sa_flags = 0; sigemptyset(&dfl.sa_mask); +#if defined(__sun) + /* workaround for Solaris 10: grantpt() doesn't work if FD_CLOEXEC is set. [ruby-dev:44688] */ + if ((masterfd = posix_openpt(O_RDWR|O_NOCTTY)) == -1) goto error; + if (sigaction(SIGCHLD, &dfl, &old) == -1) goto error; + if (grantpt(masterfd) == -1) goto grantpt_error; + rb_fd_set_cloexec(masterfd); +#else if ((masterfd = posix_openpt(O_RDWR|O_NOCTTY)) == -1) goto error; rb_fd_set_cloexec(masterfd); if (sigaction(SIGCHLD, &dfl, &old) == -1) goto error; if (grantpt(masterfd) == -1) goto grantpt_error; +#endif if (sigaction(SIGCHLD, &old, NULL) == -1) goto error; if (unlockpt(masterfd) == -1) goto error; if ((slavedevice = ptsname(masterfd)) == NULL) goto error; @@ -365,10 +373,18 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg, extern int unlockpt(int); extern int grantpt(int); +#if defined(__sun) + /* workaround for Solaris 10: grantpt() doesn't work if FD_CLOEXEC is set. [ruby-dev:44688] */ + if((masterfd = open("/dev/ptmx", O_RDWR, 0)) == -1) goto error; + s = signal(SIGCHLD, SIG_DFL); + if(grantpt(masterfd) == -1) goto error; + rb_fd_set_cloexec(masterfd); +#else if((masterfd = open("/dev/ptmx", O_RDWR, 0)) == -1) goto error; rb_fd_set_cloexec(masterfd); s = signal(SIGCHLD, SIG_DFL); if(grantpt(masterfd) == -1) goto error; +#endif signal(SIGCHLD, s); if(unlockpt(masterfd) == -1) goto error; if((slavedevice = ptsname(masterfd)) == NULL) goto error; |