Index of Section 2 Manual Pages

Interix / SUAttyslot.2Interix / SUA

ttyslot(2)                                                   ttyslot(2)

  ttyname()

  NAME

    ttyname(), ttyname_r(), isatty(), ttyslot() - get pathname of associated
    terminal (tty) from file descriptor

  SYNOPSIS

    #include 

    char * ttyname (int fd)
    int ttyname_r (int fildes, char *name, size_t namesize)
    int isatty (int fd)
    int ttyslot (void)

  DESCRIPTION

    These functions operate on the system file descriptors for terminal type
    devices.

    The isatty(2) function determines if the file descriptor fd refers to a
    valid terminal type device (serial devices, console windows and pseudo
    ttys).

    The ttyname(2) function gets the related device name of a file descriptor
    for which isatty(2) is true. The name has the form /dev/ttyident, where
    the ident string specifies the type of the device and identifies it.

    The reentrant ttyname_r(2) function stores the null-terminated pathname of
    the terminal associated with the file descriptor identified by the fildes
    argument in the character array referenced by name. The array is namesize
    characters long and must have space for the name and the terminating null
    character. The maximum length of the terminal name is {TTY_NAME_MAX}.

    The ttyslot(2) function returns the index for the curent user's place in /
    var/adm/utmpx file, the user accounting database. The first entry is 0;
    the record represents the user's line. (A user's line in the database is
    an entry where utline matches the terminal device for one of the standard
    streams.)

  RETURN VALUES

    The ttyname(2) function returns the null-terminated name if the tty device
    is found and isatty(2) is true; otherwise it returns NULL and sets errno.

    On success, the ttyname_r(2) function returns zero. Otherwise, it returns
    an error number to indicate the error.

    The ttyslot(2) function returns the index number for the entry; on
    failure, it returns -1 if there was an error, or if none of standard
    input, output or error for the process is associated with a terminal
    device.

    The isatty(2) call returns zero if fd is not a valid terminal device and
    non-zero if it is.

  ERROR

    The ttyname(2), ttyname_r(2), and isatty(2) functions can fail for the
    following reasons:

    [EBADF]
        The fd argument is not a valid descriptor.

    [EIO]
        Although the fd argument refers to a valid descriptor, the terminal
        device is no longer responsive.

    [ENOTTY]
        The fd argument does not refer to a terminal device.

    In addition, the ttyname_r(2) function can fail for the following reason:

    [ERANGE]
        The value of namesize is smaller than the length of the string to be
        returned including the terminating null character

  FILES

    /dev/*
        The virtual device directory.

  SEE ALSO

    ctermid(3)

  USAGE NOTES

    The isatty, ttyname_r, ttyslot functions are thread safe. The ttyname
    function is not thread safe.

    None of these functions are async-signal safe.


Interix / SUAHosted at SUA Community for Interix, SUA and SFUInterix / SUA