CTERMID(3S) UNIX Programmer's Manual CTERMID(3S) NAME ctermid - generate file name for terminal SYNOPSIS #include char *ctermid(s) char *s; HP-UX COMPATIBILITY Level: HP-UX/RUN ONLY Origin: System III DESCRIPTION _C_t_e_r_m_i_d generates a string that refers to the controlling terminal for the current process when used as a file name. If (int)_s is zero, the string is stored in an internal static area, the contents of which are overwritten at the next call to _c_t_e_r_m_i_d, and the address of which is returned. If (int)_s is non-zero, then _s is assumed to point to a char- acter array of at least L_ctermid elements; the string is placed in this array and the value of _s is returned. The manifest constant L_ctermid is defined in . The difference between _c_t_e_r_m_i_d and _t_t_y_n_a_m_e(3C) is that _t_t_y_n_a_m_e must be handed a file descriptor and returns the actual name of the terminal associated with that file descriptor, while _c_t_e_r_m_i_d returns a magic string (/dev/tty) that will refer to the terminal if used as a file name. Thus _t_t_y_n_a_m_e is useless unless the process already has at least one file open to a terminal. SEE ALSO ttyname(3C).