mkostemp(3c) 맨 페이지 - 윈디하나의 솔라나라

개요

섹션
맨 페이지 이름
검색(S)

mkostemp(3c)

Standard C Library Functions                                       mkstemp(3C)



NAME
       mkstemp, mkstemps, mkostemp, mkostemps - make a unique file name from a
       template and open the file

SYNOPSIS
       #include <stdlib.h>

       int mkstemp(char *template);


       int mkstemps(char *template, int slen);


       #include <stdlib.h>
       #include <fcntl.h>

       int mkostemp(char *template, int flags);


       int mkostemps(char *template, int slen, int flags);

DESCRIPTION
       The mkstemp() function replaces the contents of the string  pointed  to
       by  template  by  a unique file name, and returns a file descriptor for
       the file open for reading and writing. The function thus  prevents  any
       possible  race  condition  between  testing whether the file exists and
       opening it for use. The string in template should look like a file name
       with  six  trailing  'X's; mkstemp() replaces each 'X' with a character
       from the portable file name character set. The  characters  are  chosen
       such that the resulting name does not duplicate the name of an existing
       file.


       The mkstemps() function behaves the same as mkstemp(), except  it  per‐
       mits  a  suffix to exist in the template. The template should be of the
       form /tmp/tmpXXXXXXsuffix. The slen parameter specifies the  length  of
       the suffix string.


       The  mkostemp()  and mkostemps() functions behave the same as mkstemp()
       and mkstemps() functions respectively, except that they  take  a  flags
       parameter  to  specify flags to be passed to open(2) in addition to the
       default O_CREAT | O_EXCL | O_RDWR flags.

RETURN VALUES
       Upon  successful  completion,  these  functions  return  an  open  file
       descriptor.  Otherwise −1 is returned if no suitable file could be cre‐
       ated.

ERRORS
       These functions can set errno  to  the  same  values  as  lstat(2)  and
       open(2).

USAGE
       It is possible to run out of letters.


       These functions do not check to determine whether the file name part of
       template exceeds the maximum allowable file name length.


       These functions are frequently used to create  a  temporary  file  that
       will be removed by the application before the application terminates.


       The  tmpfile(3C)  function is preferred over the mkstemp() function for
       creating temporary files when control is  not  needed  over  the  path,
       name, and flags used to open(2) the file.


       These  functions  have transitional interfaces for 64-bit file offsets.
       See lf64(7).


       The mkostemp() and mkostemps() functions allow atomically applying  the
       O_CLOEXEC  and  O_CLOFORK  flags to the file descriptor when it is cre‐
       ated, with no opportunity for other threads to call  functions  in  the
       fork  or exec families between the open() call and a call to fcntl() to
       set such flags, thus aiding in thread safety.

ATTRIBUTES
       See attributes(7) for descriptions of the following attributes:


       tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) ATTRIBUTE  TYPEAT‐
       TRIBUTE VALUE _ Interface StabilityCommitted _ StandardSee below.



       See standards(7) for descriptions of the following standards:


       tab()  box;  cw(2.2i) |cw(3.3i) lw(2.2i) |lw(3.3i) INTERFACESAPPLICABLE
       STANDARDS _
         mkstemp()
       T{
         POSIX.1-2001 through 2008,
         SUS through SUSv4,
         XPG4v2 through XPG7

       T} _ T{
         mkstemps()
         mkostemp()
         mkostemps()

       T} None


SEE ALSO
       getpid(2), open(2), mktemp(3C),  tmpfile(3C),  attributes(7),  lf64(7),
       standards(7)

HISTORY
       The  mkstemp()  function  was  added to SunOS in SunOS 4.0 and has been
       included in all Sun and Oracle releases of Solaris.


       The mkstemps() function was defined in OpenBSD 2.4, and  was  added  to
       Oracle Solaris in the Oracle Solaris 11.0 release.


       The mkostemp() and mkostemps() functions were defined in GNU libc 2.11,
       and were added to Oracle Solaris in the Oracle Solaris 11.4.15 release.



Oracle Solaris 11.4               5 Aug 2019                       mkstemp(3C)
맨 페이지 내용의 저작권은 맨 페이지 작성자에게 있습니다.
RSS ATOM XHTML 5 CSS3