The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group

 NAME

ctermid - generate a pathname for controlling terminal

 SYNOPSIS



#include <stdio.h>

char *ctermid(char *s);

 DESCRIPTION

The 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.

If the application uses any of the _POSIX_THREAD_SAFE_FUNCTIONS or _POSIX_THREADS interfaces, the ctermid() function must be called with a non-NULL parameter.

 RETURN VALUE

If s is a null pointer, the string is generated in an area that may be static (and therefore may be overwritten by each call), the address of which is returned. Otherwise 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 will have a value greater than 0.

The ctermid() function will return an empty string if the pathname that would refer to the controlling terminal cannot be determined, or if the function is unsuccessful.

 ERRORS

No errors are defined.

 EXAMPLES

None.

 APPLICATION USAGE

The difference between ctermid() and ttyname() is that ttyname() must be handed a file descriptor and returns a path of the terminal associated with that file descriptor, while ctermid() returns a string (such as /dev/tty) that will refer to the current controlling terminal if used as a pathname.

 FUTURE DIRECTIONS

None.

 SEE ALSO

ttyname(), <stdio.h>.

DERIVATION

Derived from Issue 1 of the SVID.

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]