Oops - I rushed to switch to mkstemp without realizing it doesn't return the char* path the same way mktemp does, and it has the side-effect of opening the file.