mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-10 23:24:39 +00:00
Change to detect and use O_CLOEXEC
This commit is contained in:
parent
8b26d0104c
commit
17a75a5aa5
1 changed files with 7 additions and 0 deletions
|
@ -201,6 +201,13 @@ bool set_cloexec(int fd) {
|
|||
static int wopen_internal(const wcstring &pathname, int flags, mode_t mode, bool cloexec)
|
||||
{
|
||||
cstring tmp = wcs2string(pathname);
|
||||
/* Prefer to use O_CLOEXEC. It has to both be defined and nonzero */
|
||||
#ifdef O_CLOEXEC
|
||||
if (cloexec && O_CLOEXEC) {
|
||||
flags |= O_CLOEXEC;
|
||||
cloexec = false;
|
||||
}
|
||||
#endif
|
||||
int fd = ::open(tmp.c_str(), flags, mode);
|
||||
if (cloexec && fd >= 0 && ! set_cloexec(fd)) {
|
||||
close(fd);
|
||||
|
|
Loading…
Reference in a new issue