aboutsummaryrefslogtreecommitdiff
path: root/src/backend/storage/file/fd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/storage/file/fd.c')
-rw-r--r--src/backend/storage/file/fd.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c
index ea690f05c69..9fd8444ed4d 100644
--- a/src/backend/storage/file/fd.c
+++ b/src/backend/storage/file/fd.c
@@ -1515,6 +1515,14 @@ PathNameOpenFilePerm(const char *fileName, int fileFlags, mode_t fileMode)
/* Close excess kernel FDs. */
ReleaseLruFiles();
+ /*
+ * Descriptors managed by VFDs are implicitly marked O_CLOEXEC. The
+ * client shouldn't be expected to know which kernel descriptors are
+ * currently open, so it wouldn't make sense for them to be inherited by
+ * executed subprograms.
+ */
+ fileFlags |= O_CLOEXEC;
+
vfdP->fd = BasicOpenFilePerm(fileName, fileFlags, fileMode);
if (vfdP->fd < 0)