The difference between ctermid() and ttyname(3C) is that ttyname() must be passed a file descriptor and returns the actual name of the terminal
associated with that file descriptor, while ctermid() returns a string (/dev/tty) that will refer to the terminal if used as a file name. The ttyname() function is useful only if the process already has at least one file open to a terminal.
The ctermid() function is unsafe in multithreaded applications. The ctermid_r() function is MT-Safe and should be used instead.
When compiling multithreaded applications, the _REENTRANT flag must be defined on the compile line. This flag should be used only with multithreaded applications.
|