Check for TMPDIR and if set use it

This commit is contained in:
sin 2013-11-14 19:46:21 +00:00
parent a7b8eee6c0
commit 91a643411d
1 changed files with 4 additions and 1 deletions

View File

@ -19,7 +19,7 @@ int
main(int argc, char *argv[])
{
char *template = "tmp.XXXXXXXXXX";
char *tmpdir = "/tmp";
char *tmpdir = "/tmp", *p;
char tmppath[PATH_MAX];
int fd;
@ -39,6 +39,9 @@ main(int argc, char *argv[])
else if (argc == 1)
template = argv[0];
if ((p = getenv("TMPDIR")))
tmpdir = p;
snprintf(tmppath, sizeof(tmppath), "%s/%s", tmpdir, template);
if (dflag) {
if (!mkdtemp(tmppath)) {