Reuben Thomas <[email protected]> writes:

> I'm trying to rewrite some code that uses tmpname to use mkstemp.
> Unfortunately, I can't see a simple way to get a good location for
> temporary files independently of tmpname. P_tmpdir is obsolescent and
> optional, and it seems that there's no other POSIX way to get at "the
> path commonly known as /tmp".

Am I missing something, or why couldn't you use getenv("TMPDIR")?  It is
defined by POSIX:

http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html

If it is not available, falling back to "/tmp" would not be an error as
far as I can tell.  POSIX environments should have TMPDIR defined.

/Simon

Reply via email to