9.79 ttyname

int ttyname(int fd, char *buffer, size_t size);

This syscall fetches the name of the filesystem entity backing a TTY and writes it to buffer with a NULL terminator.

The syscall returns 0 on success or -1 on failure, with the following errno:

EINVAL

size is less than needed and/or fd is not a TTY.

EBADF

fd is not opened to anything.

EFAULT

buffer points to invalid memory.