diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2012-03-02 09:58:29 -0800 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2012-03-02 09:58:29 -0800 |
commit | 17a75a5aa5039de8359b859b7631e135cbdef81b (patch) | |
tree | 4073348f759615e6270720ea4a50e30fd159286d /wutil.cpp | |
parent | 8b26d0104c1d85c271e5ce6e08bfe64a779beba7 (diff) |
Change to detect and use O_CLOEXEC
Diffstat (limited to 'wutil.cpp')
-rw-r--r-- | wutil.cpp | 7 |
1 files changed, 7 insertions, 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); |