- strncpy (tmpfil, m_tmpfil ("dist"), sizeof(tmpfil));
- if ((hdrfd = open (tmpfil, O_RDWR | O_CREAT | O_TRUNC, 0600)) == NOTOK)
- adios (tmpfil, "unable to re-open temporary file");
+ cp = m_mktemp2(NULL, "dist", &hdrfd, NULL);
+ if (cp == NULL) {
+ adios(NULL, "unable to create temporary file in %s", get_temp_dir());
+ }
+ strncpy(tmpfil, cp, sizeof(tmpfil));