terminal-name

terminal-name is a built-in function in `C source code'.

(terminal-name &optional TERMINAL)

Return the name of the terminal device TERMINAL.
It is not guaranteed that the returned value is unique among opened devices.

TERMINAL may be a terminal object, a frame, or nil (meaning the
selected frame's terminal).