Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
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);

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

   POSIX
       cc [ flag ...] file ... -D_POSIX_PTHREAD_SEMANTICS [ library ...	]

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

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	may point to static data whose
       content is overwritten by each call.

       The ttyname_r() function	has the	same functionality as ttyname()	except
       that  the caller	must supply a buffer name with length namelen to store
       the result; this	buffer must be at least	_POSIX_PATH_MAX	  in size (de-
       fined  in  <limits.h>).	The  POSIX  version (see standards(5)) of tty-
       name_r()	takes a	namesize parameter of type size_t.

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

       The POSIX ttyname_r() returns zero if successful, or the	 error	number
       upon failure.

ERRORS
       The ttyname_r() function	will fail if:

       ERANGE
	     The size of the buffer is smaller than the	result to be returned.

       The ttyname() function may fail if:

       EBADF The fildes	argument is not	a valid	file descriptor.

       ENOTTY
	     The fildes	argument does not refer	to a terminal device.

FILES
       /dev/*
	     device file

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

       +-----------------------------+-----------------------------+
       |      ATTRIBUTE	TYPE	     |	    ATTRIBUTE VALUE	   |
       +-----------------------------+-----------------------------+
       |MT-Level		     |See NOTES	below.		   |
       +-----------------------------+-----------------------------+

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

NOTES
       When  compiling	multithreaded  programs, see Intro(3), Notes On	Multi-
       threaded	Applications.

       If the application is linked with -lintl, then  messages	 printed  from
       this  function  are in the native language specified by the LC_MESSAGES
       locale category;	see setlocale(3C).

       The return value	points to static data whose content is overwritten  by
       each call.

       The ttyname() is	Unsafe in multithreaded	applications.  The ttyname_r()
       function	is MT-Safe, and	should be used instead.

       Solaris 2.4 and earlier	releases  provided  definitions	 of  the  tty-
       name_r()	interface as specified in POSIX.1c Draft 6. The	final POSIX.1c
       standard	changed	the interface as  described  above.  Support  for  the
       Draft  6	 interface  is	provided for compatibility only	and may	not be
       supported in future releases. New applications and libraries should use
       the POSIX standard interface.

SunOS 5.9			  20 Mar 1997			   ttyname(3C)

NAME | SYNOPSIS | DESCRIPTION | RETURN VALUES | ERRORS | FILES | ATTRIBUTES | SEE ALSO | NOTES

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=ttyname&sektion=3c&manpath=SunOS+5.9>

home | help