[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

Technical Reference: Base Operating System and Extensions, Volume 1

ctermid Subroutine


Generates the path name of the controlling terminal.


Standard C Library (libc.a)


#include <stdio.h>
char *ctermid ( String)
char *String;


The ctermid subroutine generates the path name of the controlling terminal for the current process and stores it in a string.

Note: File access permissions depend on user access. Access to a file whose path name the ctermid subroutine has returned is not guaranteed.

The difference between the ctermid and ttyname subroutines is that the ttyname subroutine must be handed a file descriptor and returns the actual name of the terminal associated with that file descriptor. The ctermid subroutine returns a string (the /dev/tty file) that refers to the terminal if used as a file name. Thus, the ttyname subroutine is useful only if the process already has at least one file open to a terminal.


String If the String parameter is a null pointer, the string is stored in an internal static area and the address is returned. The next call to the ctermid subroutine overwrites the contents of the internal static area.

If the String parameter is not a null pointer, it points to a character array of at least L_ctermid elements as defined in the stdio.h file. The path name is placed in this array and the value of the String parameter is returned.

Implementation Specifics

This subroutine is part of Base Operating System (BOS) Runtime.

Related Information

The isatty or ttyname subroutine.

Input and Output Handling Programmer's Overview in AIX 5L Version 5.1 General Programming Concepts: Writing and Debugging Programs.

[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]