views:

129

answers:

2

A program I use is failing when it uses tmpfile() for large files. The problem seems to be I don't have permission to create large files in /tmp, which this function uses by default. So is there a way, perhaps with an environmental variable, that I can make tmpfile() write to a different location?

Edit: the program in question is sox, which uses C.

+3  A: 

You can use the environment variable TMPDIR to to tell tmpfile() where to create files:

sh syntax:

TMPDIR=/path/to/whatever; export TMPDIR

csh syntax:

setenv TMPDIR /path/to/whatever
R Samuel Klatchko
+1  A: 

Given the information in man tmpfile (3) you may want to: #define P_tmpdir "/somedir" Of course, this probably isn't too reliable.

You can also set your environmental variable, TMPDIR to some location.

Nick Presta