/*! \brief Use mkstemp (or similar function to make a new temporary
* file and (on non-Windows systems) return a file descriptor to it.
*
+ * Note: not thread-safe on non-Windows systems
+ *
* \todo Use std::string and std::vector<char>. */
static int makeTemporaryFilename(char* buf)
{
#else
int fd = mkstemp(buf);
+ /* mkstemp creates 0600 files - respect umask instead */
+ mode_t currUmask = umask(0);
+ umask(currUmask);
+ fchmod(fd, 0666 & ~currUmask);
+
if (fd < 0)
{
gmx_fatal(FARGS, "Error creating temporary file %s: %s", buf, strerror(errno));