Subject to exactly the same race condition you had with tempnam(), see comments above.