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)
*/
DIR *vlc_opendir (const char *dirname)
{
const char *local_name = ToLocale (dirname);
if (unlikely(local_name == NULL))
{
errno = ENOENT;
#ifdef O_DIRECTORY
int fd = vlc_open (dirname, O_RDONLY | O_DIRECTORY);
#else /* If O_DIRECTORY is missing. fdopendir() will deal with ENOTDIR. */
int fd = vlc_open (dirname, O_RDONLY);
#endif
if (fd == -1)
return NULL;
}
DIR *dir = opendir (local_name);
LocaleFree (local_name);
DIR *dir = fdopendir (fd);
if (dir == NULL)
close (fd);
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