createTempFile(): Mark file as CLOEEXEC

Fixes #5674.
This commit is contained in:
Eelco Dolstra 2021-11-29 11:20:50 +01:00
parent e1420c66a4
commit 6e0cbc666b

View file

@ -512,6 +512,7 @@ std::pair<AutoCloseFD, Path> createTempFile(const Path & prefix)
AutoCloseFD fd(mkstemp((char *) tmpl.c_str())); AutoCloseFD fd(mkstemp((char *) tmpl.c_str()));
if (!fd) if (!fd)
throw SysError("creating temporary file '%s'", tmpl); throw SysError("creating temporary file '%s'", tmpl);
closeOnExec(fd.get());
return {std::move(fd), tmpl}; return {std::move(fd), tmpl};
} }