diff options
author | Max Kellermann <max@duempel.org> | 2014-08-07 18:16:11 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-08-07 18:16:11 +0200 |
commit | bbea6564fc454feb722241c4469ccbd0ce32aa01 (patch) | |
tree | 5e630ec7dd7b51a881d0ea62570775f8c5b848aa | |
parent | 1ca8d7ad4527b228a4f2f25409ce5e939a14141c (diff) | |
download | mpd-bbea6564fc454feb722241c4469ccbd0ce32aa01.tar.gz mpd-bbea6564fc454feb722241c4469ccbd0ce32aa01.tar.xz mpd-bbea6564fc454feb722241c4469ccbd0ce32aa01.zip |
fs/output/FileOutputStream: use open_cloexec()
Support operating systems that don't have O_CLOEXEC.
-rw-r--r-- | src/fs/output/FileOutputStream.cxx | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/fs/output/FileOutputStream.cxx b/src/fs/output/FileOutputStream.cxx index 68c46acee..dc4456d1f 100644 --- a/src/fs/output/FileOutputStream.cxx +++ b/src/fs/output/FileOutputStream.cxx @@ -20,6 +20,7 @@ #include "config.h" #include "FileOutputStream.hxx" #include "fs/FileSystem.hxx" +#include "system/fd_util.h" #include "util/Error.hxx" #ifdef WIN32 @@ -81,9 +82,9 @@ FileOutputStream::Cancel() FileOutputStream::FileOutputStream(Path _path, Error &error) :path(_path), - fd(open(path.c_str(), - O_WRONLY|O_CLOEXEC|O_CREAT|O_TRUNC|O_NOCTTY, - 0666)) + fd(open_cloexec(path.c_str(), + O_WRONLY|O_CREAT|O_TRUNC, + 0666)) { if (fd < 0) error.FormatErrno("Failed to create %s", path.c_str()); |