692 |
} |
} |
693 |
} |
} |
694 |
|
|
695 |
/* Create and open a temporary file. Be vary careful about it, since we |
/* Create and open a temporary file. Be very careful about it, since we |
696 |
may be running with extra privilege i.e setgid(). |
may be running with extra privilege i.e setgid(). |
697 |
Returns file descriptor of the open file. |
Returns file descriptor of the open file. |
698 |
If namep is not NULL, the pointer to the malloced file name will |
If namep is not NULL, the pointer to the malloced file name will |
748 |
return fd; |
return fd; |
749 |
} |
} |
750 |
|
|
751 |
|
/* Create a unique temporary file name in tmpdir. The function |
752 |
|
creates an empty file with this name to avoid possible race |
753 |
|
conditions. Returns a pointer to the malloc'ed file name. |
754 |
|
If tmpdir is NULL, the value of the environment variable |
755 |
|
TMPDIR or the hardcoded P_tmpdir is used, whichever is defined. */ |
756 |
|
|
757 |
|
char * |
758 |
|
mu_tempname (const char *tmpdir) |
759 |
|
{ |
760 |
|
char *filename = NULL; |
761 |
|
int fd = mu_tempfile (tmpdir, &filename); |
762 |
|
close (fd); |
763 |
|
return filename; |
764 |
|
} |
765 |
|
|
766 |
/* See Advanced Programming in the UNIX Environment, Stevens, |
/* See Advanced Programming in the UNIX Environment, Stevens, |
767 |
* program 10.20 for the rational for the signal handling. I |
* program 10.20 for the rational for the signal handling. I |
768 |
* had to look it up, so if somebody else is curious, thats where |
* had to look it up, so if somebody else is curious, thats where |