From 5ebf7a3c8821504ebf9f1d04b7cf9ac0ec9486a2 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Fri, 26 Jul 2013 13:33:09 +0200 Subject: [PATCH] Set O_CLOEXEC in opendir(3). --- libc/fddir-sortix.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libc/fddir-sortix.c b/libc/fddir-sortix.c index 6f3c5c1c..2a666389 100644 --- a/libc/fddir-sortix.c +++ b/libc/fddir-sortix.c @@ -131,9 +131,7 @@ DIR* fdopendir(int fd) DIR* opendir(const char* path) { - // TODO: POSIX says we should use O_CLOEXEC here. That seems quite hacky to - // me. Is that stupid? If so, I'll leave it out. - int fd = open(path, O_SEARCH | O_DIRECTORY); + int fd = open(path, O_SEARCH | O_DIRECTORY | O_CLOEXEC); if ( fd < 0 ) { return NULL; } DIR* dir = fdopendir(fd); if ( !dir ) { close(fd); return NULL; }