HELPLIB.HLB  —  CRTL  ttyname
    Find the pathname of a terminal.

    Format

      #include  <unixio.h> (Compatibility)

      char *ttyname  (void); (Compatibility)

      #include  <unistd.h> (OpenVMS V7.3-2 and higher)

      char *ttyname  (int filedes); (OpenVMS V7.3-2 and higher)

      int ttyname_r  (int filedes, char name, size_t

                     namesize); (OpenVMS V7.3-2 and higher),

                     (Integrity servers, Alpha)

1  –  Arguments

 filedes

    An open file descriptor.

 name

    Pointer to a buffer in which the terminal name is stored.

 namesize

    The length of the buffer pointed to by the name argument.

2  –  Description

    The implementation of the ttyname function that takes no
    argument is provided only for backward compatibility. This
    legacy implementation returns a pointer to the null-terminated
    name of the terminal device associated with file descriptor 0,
    the default input device (stdin). A value of 0 is returned if
    SYS$INPUT is not a TTY device.

    The ttyname_r function and the implementation of ttyname that
    takes a filedes argument are UNIX standard compliant and are
    available with only OpenVMS Version 7.3-2 and higher.

    The standard compliant ttyname function returns a pointer to a
    string containing a null-terminated pathname of the terminal
    associated with file descriptor filedes. The return value might
    point to static data whose content is overwritten by each call.
    The ttyname interface need not be reentrant.

    The ttyname_r function returns a pointer to store the null-
    terminated pathname of the terminal associated with the file
    descriptor filedes in the character array referenced by name. The
    array is namesize characters long and should have space for the
    name and the terminating null character. The maximum length of
    the terminal name is TTY_NAME_MAX.

    If successful, ttyname returns a pointer to a string. Otherwise,
    a NULL pointer is returned and errno is set to indicate the
    error.

    If successful, ttyname_r stores the terminal name as a null-
    terminated string in the buffer pointed to by name and returns 0.
    Otherwise, an error number is returned to indicate the error.

3  –  Return Values

    x                  Upon successful completion, ttyname returns a
                       pointer to a null-terminated string.
    NULL               Upon failure, ttyname returns a NULL pointer
                       and sets errno to indicate the failure:

                       o  EBADF - The fildes argument is not a valid
                          file descriptor.

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

    0                  Upon successful completion, ttyname_r returns
                       0.
    n                  Upon failure, ttyname_r sets errno to indicate
                       the failure, and returns the same errno code:

                       o  EBADF - The fildes argument is not a valid
                          file descriptor.

                       o  ENOTTY - The fildes argument does not refer
                          to a TTY device.

                       o  ERANGE - The value of namesize is smaller
                          than the length of the string to be
                          returned including the terminating null
                          character.

    0                  For the legacy ttyname, indicates that
                       SYS$INPUT is not a TTY device.
Close Help