Open System Services System Calls Reference Manual (G06.28+)

System Functions (a - d) ctermid_r(2)
NAME
ctermid_r - Generates the pathname for the controlling terminal (reentrant)
LIBRARY
G-series native OSS processes: /G/system/sysnn/zsptsrl
H-series OSS processes: /G/system/zdllnnn/zsptdll
SYNOPSIS
[#include <stdio.h>]
#include <spthread.h>
char *ctermid_r (
char *s );
PARAMETERS
s Indicates where to store the returned pathname. If the s parameter is a null
pointer, the function returns a null character string.
If the s parameter is not a null pointer, it points to a character array of at least
L_ctermid bytes. The symbolic constant L_ctermid is dened in the stdio.h
header le and has a value greater than 0 (zero). The pathname is placed in this
array and the value of the s parameter is returned.
DESCRIPTION
The ctermid_r() function is the reentrant version of the ctermid() function.
The ctermid_r() function generates the pathname to the controlling terminal for the current pro-
cess and stores it in a string.
The ctermid_r() function differs from the ttyname() function in that the ttyname() function is
supplied a le descriptor and returns the actual name of the terminal associated with that le
descriptor, while the ctermid_r() function returns a string (/dev/tty) that refers to the controlling
terminal if used as a pathname. ctermid_r() returns a pathname, which can be used in the
open() function to access the controlling terminal (if a controlling terminal exists). The existence
of a controlling terminal is checked in open(). The ttyname() function returns the pathname of
a terminal type le descriptor.
RETURN VALUES
The ctermid_r() function returns the address of the generated pathname. Otherwise, a null
string is returned. Access to a pathname returned by the ctermid_r() function is not guaranteed.
For Guardian TNS or accelerated processes, a null pathname is returned and errno is set to
[ENOTOSS].
ERRORS
If any of the following conditions occur, the ctermid_r() function sets errno to the correspond-
ing value:
[ENOMEM] A null pointer was passed and static memory was not available to complete the
request.
[ENOTOSS] The program has called a function that can be called only from an OSS process
or from a Guardian native process.
RELATED INFORMATION
Functions: ctermid(3), ttyname(3), ttyname_r(2).
527186-005 Hewlett-Packard Company 139