Honor TMPDIR environment variable

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4033 c046a42c-6fe2-441c-8c8c-71466251a162
stable-0.10
aurel32 2008-03-10 00:05:34 +00:00
parent e94bbefe59
commit 0badc1ee0e
1 changed files with 5 additions and 1 deletions

View File

@ -191,8 +191,12 @@ void get_tmp_filename(char *filename, int size)
void get_tmp_filename(char *filename, int size)
{
int fd;
char *tmpdir;
/* XXX: race condition possible */
pstrcpy(filename, size, "/tmp/vl.XXXXXX");
tmpdir = getenv("TMPDIR");
if (!tmpdir)
tmpdir = "/tmp";
snprintf(filename, size, "%s/vl.XXXXXX", tmpdir);
fd = mkstemp(filename);
close(fd);
}