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

개요

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

ttyname(3c)

ttyname(3C)              Standard C Library Functions              ttyname(3C)

NAME
       ttyname, ttyname_r - find pathname of a terminal

SYNOPSIS
       #include <unistd.h>

       char *ttyname(int fildes);


       int ttyname_r(int fildes, char *name, size_t namesize);

   POSIX.1c Draft 6
       #define __USE_DRAFT6_PROTOTYPES__
       #include <time.h>

       char *ttyname_r(int fildes, char *name, int namelen);

DESCRIPTION
       The  ttyname()  function  returns  a pointer to a string containing the
       null-terminated path name of the terminal device associated  with  file
       descriptor  fildes.  The  return  value  points to thread-specific data
       whose content is overwritten by each call from the same thread.


       The ttyname_r() function has the same functionality as ttyname() except
       that the caller must supply a buffer name with size namesize  to  store
       the  result; this buffer must be at least _POSIX_PATH_MAX bytes in size
       (defined in <limits.h>).

RETURN VALUES
       Upon successful completion, ttyname() returns a pointer  to  a  string.
       Otherwise,  a null pointer is returned and errno is set to indicate the
       error.


       The ttyname_r() function returns 0 if successful or  the  error  number
       upon failure; it does not set errno.

ERRORS
       The ttyname() and ttyname_r() functions may fail if:

       EBADF     The fildes argument is not a valid file descriptor. This con‐
                 dition is reported.


       ENOTTY    The fildes argument does not refer to a terminal device. This
                 condition is reported.



       The ttyname_r() function may fail if:

       ERANGE    The  value  of  namesize  is  smaller  than the length of the
                 string to be returned including the terminating null  charac‐
                 ter.


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 _ MT-LevelSafe _ Standard‐
       See standards(7).


SEE ALSO
       gettext(3C), setlocale(3C), ttysrch(5), attributes(7), standards(7)

NOTES
       Messages printed from this function are in the native  language  speci‐
       fied by the LC_MESSAGES locale category. See setlocale(3C).


       The return value of ttyname() points to thread-specific data whose con‐
       tent is overwritten by each call from the same thread, and which may be
       invalidated  if the calling thread is terminated. This function is safe
       to use in multithreaded applications, but its use is  discouraged.  The
       ttyname_r() function should be used instead.


       Prior  to Oracle Solaris 11.4, the default compilation environment pro‐
       vided a definition of the ttyname_r() function as specified in POSIX.1c
       Draft 6. The final POSIX.1c standard changed  the  interface  for  tty‐
       name_r().  To  allow applications that were written to use the obsolete
       Draft-6  interfaces  to  continue  to  be   compiled   and   run,   the
       __USE_DRAFT6_PROTOTYPES__ macro must be defined:

         cc -D__USE_DRAFT6_PROTOTYPES__ ...



       Support for the Draft-6 interfaces is provided for source compatibility
       only  and  might  not be supported in future releases. Old applications
       should be converted to use the standard definitions.

HISTORY
       Oracle Solaris 11.4.0 made the  standards-conforming  version  of  tty‐
       name_r()  the  default  definition,  removing the requirement to define
       _POSIX_C_SOURCE  or  _POSIX_PTHREAD_SEMANTICS  before   including   the
       header,  and adding the requirement to define __USE_DRAFT6_PROTOTYPES__
       to expose the Draft 6 version instead. Solaris 11.4.0 also removed  the
       requirement  to define _REENTRANT before including the header to expose
       the _r function variants.


       Solaris 2.2 added the ttyname_r() function  as  specified  in  POSIX.1c
       Draft  6.  This definition was only exposed in the header if _REENTRANT
       was defined before including the <unistd.h> header.


       The ttyname() function has been included in all Sun and Oracle releases
       of Solaris.

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