| Skip Navigation Links | |
| Exit Print View | |
![]() | man pages section 3: Basic Library Functions Oracle Solaris 11 Information Library |
enable_extended_FILE_stdio(3C)
posix_spawnattr_getschedparam(3C)
posix_spawnattr_getschedpolicy(3C)
posix_spawnattr_getsigdefault(3C)
posix_spawnattr_getsigignore_np(3C)
posix_spawnattr_getsigmask(3C)
posix_spawnattr_setschedparam(3C)
posix_spawnattr_setschedpolicy(3C)
posix_spawnattr_setsigdefault(3C)
posix_spawnattr_setsigignore_np(3C)
posix_spawnattr_setsigmask(3C)
posix_spawn_file_actions_addclose(3C)
posix_spawn_file_actions_addclosefrom_np(3C)
posix_spawn_file_actions_adddup2(3C)
posix_spawn_file_actions_addopen(3C)
posix_spawn_file_actions_destroy(3C)
posix_spawn_file_actions_init(3C)
pthread_attr_getdetachstate(3C)
pthread_attr_getinheritsched(3C)
pthread_attr_getschedparam(3C)
pthread_attr_getschedpolicy(3C)
pthread_attr_setdetachstate(3C)
pthread_attr_setinheritsched(3C)
pthread_attr_setschedparam(3C)
pthread_attr_setschedpolicy(3C)
pthread_barrierattr_destroy(3C)
pthread_barrierattr_getpshared(3C)
pthread_barrierattr_setpshared(3C)
pthread_condattr_getpshared(3C)
pthread_condattr_setpshared(3C)
pthread_cond_reltimedwait_np(3C)
pthread_key_create_once_np(3C)
pthread_mutexattr_getprioceiling(3C)
pthread_mutexattr_getprotocol(3C)
pthread_mutexattr_getpshared(3C)
pthread_mutexattr_getrobust(3C)
pthread_mutexattr_setprioceiling(3C)
pthread_mutexattr_setprotocol(3C)
pthread_mutexattr_setpshared(3C)
pthread_mutexattr_setrobust(3C)
pthread_mutex_getprioceiling(3C)
pthread_mutex_reltimedlock_np(3C)
pthread_mutex_setprioceiling(3C)
pthread_rwlockattr_destroy(3C)
pthread_rwlockattr_getpshared(3C)
pthread_rwlockattr_setpshared(3C)
pthread_rwlock_reltimedrdlock_np(3C)
pthread_rwlock_reltimedwrlock_np(3C)
pthread_rwlock_timedrdlock(3C)
pthread_rwlock_timedwrlock(3C)
rctlblk_get_enforced_value(3C)
- create a name for a temporary file
#include <stdio.h>char *tmpnam(char *s);
char *tmpnam_r(char *s);
char *tempnam(const char *dir,const char *pfx);
These functions generate file names that can be used safely for a temporaryfile.
Thetmpnam() function always generates a file name using the path prefixdefined asP_tmpdir in the <stdio.h> header. On Solaris systems, the defaultvalue forP_tmpdir is/var/tmp. Ifs isNULL,tmpnam() leaves itsresult in a thread–specific data area and returns a pointer to thatarea. The next call totmpnam() by the same thread will destroythe contents of the area. Ifs is notNULL, it isassumed to be the address of an array of at leastL_tmpnambytes, whereL_tmpnam is a constant defined through inclusion of <stdio.h>. The tmpnam() function places its result in that array and returnss.
Thetmpnam_r() function has the same functionality astmpnam() except that ifs is a null pointer, the function returnsNULL.
Thetempnam() function allows the user to control the choice of adirectory. The argumentdir points to the name of the directory inwhich the file is to be created. Ifdir isNULL orpoints to a string that is not a name for an appropriate directory,the path prefix defined asP_tmpdir in the <stdio.h> header is used.If that directory is not accessible,/tmp is used. If, however, theTMPDIR environment variable is set in the user's environment, its value is usedas the temporary-file directory.
Many applications prefer that temporary files have certain initial character sequences intheir names. Thepfx argument may beNULL or point to astring of up to five characters to be used as the initialcharacters of the temporary-file name.
Upon successful completion,tempnam() usesmalloc(3C) to allocate space for a string,puts the generated pathname in that space, and returns a pointer toit. The pointer is suitable for use in a subsequent call tofree().Iftempnam() cannot return the expected result for any reason (for example,malloc() failed), or if none of the above-mentioned attempts to find anappropriate directory was successful, a null pointer is returned anderrno is setto indicate the error.
Thetempnam() function will fail if:
Insufficient storage space is available.
These functions generate a different file name each time they are called.
Files created using these functions and eitherfopen(3C) orcreat(2) are temporaryonly in the sense that they reside in a directory intended fortemporary use, and their names are unique. It is the user's responsibilityto remove the file when its use is ended.
If called more thanTMP_MAX (defined in <stdio.h>) times in a singleprocess, these functions start recycling previously used names.
Between the time a file name is created and the file isopened, it is possible for some other process to create a filewith the same name. This can never happen if that other processis using these functions ormktemp(3C) and the file names are chosento render duplication by other means unlikely.
Thetmpnam() function is safe to use in multithreaded applications because itemploys thread-specific data if it is passed a NULL pointer. However,its use is discouraged. Thetempnam() function is safe in multithreaded applicationsand should be used instead.
When compiling multithreaded applications, the_REENTRANT flag must be defined onthe compile line. This flag should be used only with multithreadedapplications.
Seeattributes(5) for descriptions of the following attributes:
|
creat(2),unlink(2),fopen(3C),free(3C),malloc(3C),mktemp(3C),mkstemp(3C),tmpfile(3C),attributes(5),standards(5)
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.Legal Notices | ![]() ![]() |