зеркало из https://github.com/github/ruby.git
* ext/sdbm/_sdbm.c (sdbm_prep): set FD_CLOEXEC flags for file
descriptors. (fd_set_cloexec): new function. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33541 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
a5a7e2cd91
Коммит
509ed0d94f
|
@ -1,3 +1,9 @@
|
||||||
|
Fri Oct 28 06:06:08 2011 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* ext/sdbm/_sdbm.c (sdbm_prep): set FD_CLOEXEC flags for file
|
||||||
|
descriptors.
|
||||||
|
(fd_set_cloexec): new function.
|
||||||
|
|
||||||
Fri Oct 28 03:01:27 2011 Aaron Patterson <aaron@tenderlovemaking.com>
|
Fri Oct 28 03:01:27 2011 Aaron Patterson <aaron@tenderlovemaking.com>
|
||||||
|
|
||||||
* vm_insnhelper.c (vm_call_cfunc): adding back useless hack. For some
|
* vm_insnhelper.c (vm_call_cfunc): adding back useless hack. For some
|
||||||
|
|
|
@ -178,6 +178,29 @@ sdbm_open(register char *file, register int flags, register int mode)
|
||||||
return db;
|
return db;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
fd_set_cloexec(int fd)
|
||||||
|
{
|
||||||
|
/* MinGW don't have F_GETFD and FD_CLOEXEC. [ruby-core:40281] */
|
||||||
|
#ifdef F_GETFD
|
||||||
|
int flags, ret;
|
||||||
|
flags = fcntl(fd, F_GETFD); /* should not fail except EBADF. */
|
||||||
|
if (flags == -1) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (2 < fd) {
|
||||||
|
if (!(flags & FD_CLOEXEC)) {
|
||||||
|
flags |= FD_CLOEXEC;
|
||||||
|
ret = fcntl(fd, F_SETFD, flags);
|
||||||
|
if (ret == -1) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
DBM *
|
DBM *
|
||||||
sdbm_prep(char *dirname, char *pagname, int flags, int mode)
|
sdbm_prep(char *dirname, char *pagname, int flags, int mode)
|
||||||
{
|
{
|
||||||
|
@ -209,7 +232,9 @@ sdbm_prep(char *dirname, char *pagname, int flags, int mode)
|
||||||
flags |= O_BINARY;
|
flags |= O_BINARY;
|
||||||
|
|
||||||
if ((db->pagf = open(pagname, flags, mode)) == -1) goto err;
|
if ((db->pagf = open(pagname, flags, mode)) == -1) goto err;
|
||||||
|
if (fd_set_cloexec(db->pagf) == -1) goto err;
|
||||||
if ((db->dirf = open(dirname, flags, mode)) == -1) goto err;
|
if ((db->dirf = open(dirname, flags, mode)) == -1) goto err;
|
||||||
|
if (fd_set_cloexec(db->dirf) == -1) goto err;
|
||||||
/*
|
/*
|
||||||
* need the dirfile size to establish max bit number.
|
* need the dirfile size to establish max bit number.
|
||||||
*/
|
*/
|
||||||
|
|
Загрузка…
Ссылка в новой задаче