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.