Implementation status: to be implemented
char *ctermid(char *s);
ctermid() function generates a pathname for the controlling terminal.
s - a string or NULL.
ctermid() function generates a string that, when used as a pathname, refers to the current controlling terminal for the current process. If
ctermid() returns a pathname, access to the file is not guaranteed.
ctermid() function is called with a
NULL parameter, it need not be thread-safe .
If an application uses multiple threads, it cannot call
NULL as the parameter. If s is not
ctermid() function generates a string that, when used as a pathname, refers to the current controlling terminal for the current process. If s is
NULL, the return value of
ctermid() is undefined.
There is no additional burden on the programmer-changing to use a hypothetical thread-safe version of
ctermid() along with allocating a buffer is more of a burden than merely allocating a buffer. Application code should not assume that the returned string is short, as some implementations have more than two pathname components before reaching a logical device name.
If s is a null pointer, the string is generated in the static area, the address of which is returned. The application does not modify the string returned. The returned pointer might be invalidated or the string content might be overwritten by a subsequent call to
ctermid(). If the calling thread is terminated, the returned pointer be invalidated . If s is not a null pointer, s is assumed to point to a character array of at least
L_ctermid bytes; the string is placed in this array and the value of s is returned. The symbolic constant
L_ctermid is defined in
<stdio.h>, and has a value greater than
if the pathname that would refer to the controlling terminal cannot be determined or if the function is unsuccessful, then the
ctermid() function returns an empty string.
No errors are defined.
<stdio.h>file with a value greater than
0so that array declarations using it are accepted by the compiler. The value includes the terminating null byte..