Commit 7f3120af authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

posix: open directories with close-on-exec flag

parent 2a2bb7af
...@@ -162,15 +162,17 @@ int vlc_mkdir (const char *dirname, mode_t mode) ...@@ -162,15 +162,17 @@ int vlc_mkdir (const char *dirname, mode_t mode)
*/ */
DIR *vlc_opendir (const char *dirname) DIR *vlc_opendir (const char *dirname)
{ {
const char *local_name = ToLocale (dirname); #ifdef O_DIRECTORY
if (unlikely(local_name == NULL)) int fd = vlc_open (dirname, O_RDONLY | O_DIRECTORY);
{ #else /* If O_DIRECTORY is missing. fdopendir() will deal with ENOTDIR. */
errno = ENOENT; int fd = vlc_open (dirname, O_RDONLY);
#endif
if (fd == -1)
return NULL; return NULL;
}
DIR *dir = opendir (local_name); DIR *dir = fdopendir (fd);
LocaleFree (local_name); if (dir == NULL)
close (fd);
return dir; return dir;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment