header file: stdio.h
char * ctermid (char *buf)
ctermid is used on Unix systems to return the pathname of the
controlling terminal for the program.
On Unix systems terminals are devices and all devices are
accessed through a special file on the file system. Each program is
assigned a controlling terminal when it begins. Typically this is
the same terminal that the program reads to and from, but this is
not always true. This API returns the controlling terminal
pathname. This can be important when signals are being sent,
terminals are closing and programs are exiting.