Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

ttyname(3c) [opensolaris man page]

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); Standard conforming 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 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 length namelen to store the result; this buffer must be at least _POSIX_PATH_MAX in size (defined in <limits.h>). The standard-conforming version (see stan- dards(5)) of ttyname_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 standard-conforming ttyname_r() returns 0 if successful or the error number upon failure. ERRORS
The ttyname() and ttyname_r() functions may fail if: EBADF The fildes argument is not a valid file descriptor. This condition 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 character. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Safe | +-----------------------------+-----------------------------+ SEE ALSO
Intro(3), gettext(3C), setlocale(3C), attributes(5), standards(5) NOTES
When compiling multithreaded applications, see Intro(3), Notes On Multithreaded Applications. Messages printed from this function are in the native language specified by the LC_MESSAGES locale category. See setlocale(3C). The return value of ttyname() points to thread-specific data whose content is overwritten by each call from the same thread. This function is safe to use in multithreaded applications, but its use is discouraged. The ttyname_r() function should used instead. Solaris 2.4 and earlier releases provided definitions of the ttyname_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 might not be supported in future releases. New applications and libraries should use the standard-conforming interface. SunOS 5.11 31 Mar 2005 ttyname(3C)

Check Out this Related Man Page

ttyname(3)						     Library Functions Manual							ttyname(3)

NAME
ttyname, isatty, ttyname_r - Get the name of a terminal LIBRARY
Standard C Library (libc.so, libc.a) SYNOPSIS
#include <unistd.h> char *ttyname( int file-descriptor); int isatty( int file-descriptor); int ttyname_r( int file-descriptor, char *buffer, int len); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: ttyname_r(): POSIX.1c isatty(), ttyname(): XSH4.2 Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Specifies an open file descriptor. Points to a buffer in which the terminal name is stored. Specifies the length of the buffer pointed to by the buffer parameter. DESCRIPTION
The ttyname() function gets the name of a terminal. It returns a pointer to a string containing the null-terminated pathname of the termi- nal device associated with the file-descriptor parameter. The isatty() function determines if the device associated with the file-descriptor parameter is a terminal. NOTES
The ttyname() function returns a pointer to thread-specific data. Subsequent calls to this function from the same thread overwrite this data. RETURN VALUES
Upon successful completion, the ttyname() function returns a pointer to a string identifying a terminal device. A NULL pointer is returned if the file-descriptor parameter does not describe a terminal device in the /dev directory. Upon successful completion, the isatty() function returns a value of 1 if the specified file-descriptor parameter is associated with a ter- minal. Otherwise, it returns a value of zero (0). [POSIX] Upon successful completion, the ttyname_r() function stores the terminal name as a null-terminated string in the buffer pointed to by the buffer parameter and returns a value of 0 (zero). Otherwise, it returns an error number. [Tru64 UNIX] The obsolete version of ttyname_r() functions the same way as the POSIX version, except it returns a -1 upon unsuccessful completion. ERRORS
If the isatty() function fails, errno may be set to the following value: The file associated with file-descriptor is not a terminal. If the ttyname_r() function fails, errno may be set to the following value: The buffer parameter is a null pointer or the len parameter was too short to store the string. RELATED INFORMATION
Functions: ttyslot(3) Standards: standards(5) delim off ttyname(3)
Man Page