ruby-changes:21470
From: akr <ko1@a...>
Date: Mon, 24 Oct 2011 22:40:36 +0900 (JST)
Subject: [ruby-changes:21470] akr:r33519 (trunk): * ext/pty/pty.c (get_device_once): delay rb_fd_set_cloexec() until
akr 2011-10-24 22:40:13 +0900 (Mon, 24 Oct 2011) New Revision: 33519 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=33519 Log: * 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] Modified files: trunk/ChangeLog trunk/ext/pty/pty.c Index: ChangeLog =================================================================== --- ChangeLog (revision 33518) +++ ChangeLog (revision 33519) @@ -1,3 +1,10 @@ +Mon Oct 24 22:38:08 2011 Tanaka Akira <akr@f...> + + * 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] + Mon Oct 24 08:18:14 2011 Tanaka Akira <akr@f...> * io.c (copy_stream_fallback_body): check nil for EOF of read method. Index: ext/pty/pty.c =================================================================== --- ext/pty/pty.c (revision 33518) +++ ext/pty/pty.c (revision 33519) @@ -290,10 +290,18 @@ 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 @@ 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; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/