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

Technical Reference: Base Operating System and Extensions, Volume 1

ctermid Subroutine

Purpose

Generates the path name of the controlling terminal.

Library

Standard C Library (libc.a)

Syntax


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

Description

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.

Parameters

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.

Related Information

The isatty or ttyname subroutine.

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

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