fatal("Failed to create temporary file for {}: {}", path, strerror(errno));
}
- set_cloexec_flag(*fd);
+ Util::set_cloexec_flag(*fd);
#ifndef _WIN32
fchmod(*fd, 0666 & ~get_umask());
#endif
}
}
+void
+set_cloexec_flag(int fd)
+{
+#ifndef _WIN32
+ int flags = fcntl(fd, F_GETFD, 0);
+ if (flags >= 0) {
+ fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
+ }
+#else
+ (void)fd;
+#endif
+}
+
void
setenv(const std::string& name, const std::string& value)
{
// `strip_colors` is true. Throws `Error` on error.
void send_to_stderr(const std::string& text, bool strip_colors);
+// Set the FD_CLOEXEC on file descriptor `fd`. This is a NOP on Windows.
+void set_cloexec_flag(int fd);
+
// Set environment variable `name` to `value`.
void setenv(const std::string& name, const std::string& value);
# include <sys/time.h>
#endif
-void
-set_cloexec_flag(int fd)
-{
-#ifndef _WIN32
- int flags = fcntl(fd, F_GETFD, 0);
- if (flags >= 0) {
- fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
- }
-#else
- (void)fd;
-#endif
-}
-
double
time_seconds()
{
#include <string>
-void set_cloexec_flag(int fd);
double time_seconds();
logfile.open(logfile_path, "a");
#ifndef _WIN32
if (logfile) {
- set_cloexec_flag(fileno(*logfile));
+ Util::set_cloexec_flag(fileno(*logfile));
}
#endif
}