From bbea6564fc454feb722241c4469ccbd0ce32aa01 Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@duempel.org>
Date: Thu, 7 Aug 2014 18:16:11 +0200
Subject: [PATCH] fs/output/FileOutputStream: use open_cloexec()

Support operating systems that don't have O_CLOEXEC.
---
 src/fs/output/FileOutputStream.cxx | 7 ++++---
 1 file 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());