The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group

 NAME

tmpnam - create a name for a temporary file

 SYNOPSIS



#include <stdio.h>

char *tmpnam(char *s);

 DESCRIPTION

The tmpnam() function generates a string that is a valid filename and that is not the same as the name of an existing file.

The tmpnam() function generates a different string each time it is called from the same process, up to {TMP_MAX} times. If it is called more than {TMP_MAX} times, the behaviour is implementation-dependent.

The implementation will behave as if no function defined in this document calls tmpnam().

If the application uses any of the interfaces guaranteed to be available if either _POSIX_THREAD_SAFE_FUNCTIONS or _POSIX_THREADS is defined, the tmpnam() function must be called with a non-NULL parameter.

 RETURN VALUE

Upon successful completion, tmpnam() returns a pointer to a string.

If the argument s is a null pointer, tmpnam() leaves its result in an internal static object and returns a pointer to that object. Subsequent calls to tmpnam() may modify the same object. If the argument s is not a null pointer, it is presumed to point to an array of at least {L_tmpnam} chars; tmpnam() writes its result in that array and returns the argument as its value.

 ERRORS

No errors are defined.

 EXAMPLES

None.

 APPLICATION USAGE

This function only creates filenames. It is the application's responsibility to create and remove the files.

Between the time a pathname is created and the file is opened, it is possible for some other process to create a file with the same name. Applications may find tmpfile() more useful.

 FUTURE DIRECTIONS

None.

 SEE ALSO

fopen(), open(), tempnam(), tmpfile(), unlink(), <stdio.h>.

DERIVATION

Derived from Issue 1 of the SVID.

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]