[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Tempfile best practice vs. man pages



The manpages for the various ways of creating a temporary file from C are a bit
scary...

tmpnam(3): "Never use this function. Use mkstemp(3) or tmpfile(3) instead."
mktemp(3): "Never  use  mktemp()."
tempnam(3): "Never use this function. Use mkstemp(3) or tmpfile(3) instead."
mkstemp(3): "Don't use this function, use tmpfile(3) instead."
tmpfile(3): Not suitable for most applications, because it generates a 
FILE* and nothing else.

tmpfile(1): "tempfile  creates  a  temporary  file  in a safe manner.
It uses tempnam(3) to choose the name and opens it with O_RDWR | O_CREAT | O_EXCL."

I'm guessing that the dire warning on tempnam(3) is overblown.
Am I right?

-- 
Nathanael Nerode  <neroden@fastmail.fm>

Make sure your vote will count.
http://www.verifiedvoting.org/



Reply to: