Honor TMPDIR environment variable

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4033 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
aurel32 2008-03-10 00:05:34 +00:00
parent e94bbefe59
commit 0badc1ee0e

View File

@ -191,8 +191,12 @@ void get_tmp_filename(char *filename, int size)
void get_tmp_filename(char *filename, int size) void get_tmp_filename(char *filename, int size)
{ {
int fd; int fd;
char *tmpdir;
/* XXX: race condition possible */ /* 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); fd = mkstemp(filename);
close(fd); close(fd);
} }