#include "chdir-long.h"
#include "unistd--.h"
#include "xgetcwd.h"
+#include "cloexec.h"
#if GNULIB_FCNTL_SAFER
# include "fcntl--.h"
{
cwd->name = NULL;
- cwd->desc = open (".", O_RDONLY);
+ cwd->desc = open (".", O_SEARCH);
if (!GNULIB_FCNTL_SAFER)
cwd->desc = fd_safer (cwd->desc);
if (cwd->desc < 0)
return cwd->name ? 0 : -1;
}
+ set_cloexec_flag (cwd->desc, true);
return 0;
}