mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/pty/pty.c (get_device_once): use O_CLOEXEC for posix_openpt if
available. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33580 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
da5ae5544d
commit
92a8bfacd9
2 changed files with 15 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Mon Oct 31 12:37:50 2011 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* ext/pty/pty.c (get_device_once): use O_CLOEXEC for posix_openpt if
|
||||||
|
available.
|
||||||
|
|
||||||
Mon Oct 31 12:05:24 2011 Tanaka Akira <akr@fsij.org>
|
Mon Oct 31 12:05:24 2011 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* io.c (rb_cloexec_dup2): check oldfd == newfd at first.
|
* io.c (rb_cloexec_dup2): check oldfd == newfd at first.
|
||||||
|
|
|
@ -285,6 +285,7 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg,
|
||||||
int masterfd = -1, slavefd = -1;
|
int masterfd = -1, slavefd = -1;
|
||||||
char *slavedevice;
|
char *slavedevice;
|
||||||
struct sigaction dfl, old;
|
struct sigaction dfl, old;
|
||||||
|
int flags;
|
||||||
|
|
||||||
dfl.sa_handler = SIG_DFL;
|
dfl.sa_handler = SIG_DFL;
|
||||||
dfl.sa_flags = 0;
|
dfl.sa_flags = 0;
|
||||||
|
@ -297,7 +298,14 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg,
|
||||||
if (grantpt(masterfd) == -1) goto grantpt_error;
|
if (grantpt(masterfd) == -1) goto grantpt_error;
|
||||||
rb_fd_set_cloexec(masterfd);
|
rb_fd_set_cloexec(masterfd);
|
||||||
#else
|
#else
|
||||||
if ((masterfd = posix_openpt(O_RDWR|O_NOCTTY)) == -1) goto error;
|
flags = O_RDWR|O_NOCTTY;
|
||||||
|
# ifdef O_CLOEXEC
|
||||||
|
/* glibc posix_openpt() in GNU/Linux calls open("/dev/ptmx", flags) internally.
|
||||||
|
* So version dependency on GNU/Linux is same as O_CLOEXEC with open().
|
||||||
|
* O_CLOEXEC is available since Linux 2.6.23. Linux 2.6.18 silently ignore it. */
|
||||||
|
flags |= O_CLOEXEC;
|
||||||
|
# endif
|
||||||
|
if ((masterfd = posix_openpt(flags)) == -1) goto error;
|
||||||
rb_fd_set_cloexec(masterfd);
|
rb_fd_set_cloexec(masterfd);
|
||||||
if (sigaction(SIGCHLD, &dfl, &old) == -1) goto error;
|
if (sigaction(SIGCHLD, &dfl, &old) == -1) goto error;
|
||||||
if (grantpt(masterfd) == -1) goto grantpt_error;
|
if (grantpt(masterfd) == -1) goto grantpt_error;
|
||||||
|
@ -349,6 +357,7 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg,
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
#elif defined HAVE__GETPTY
|
#elif defined HAVE__GETPTY
|
||||||
|
/* SGI IRIX */
|
||||||
char *name;
|
char *name;
|
||||||
mode_t mode = nomesg ? 0600 : 0622;
|
mode_t mode = nomesg ? 0600 : 0622;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue