macro and text revision (-mdoc version 3)
[unix-history] / usr / src / lib / libc / gen / ctermid.3
.\" Copyright (c) 1990, 1991 The Regents of the University of California.
.\" All rights reserved.
.\"
.\" %sccs.include.redist.man%
.\"
.\" @(#)ctermid.3 5.2 (Berkeley) %G%
.\"
.Dd
.Dt CTERMID 3
.Os
.Sh NAME
.Nm ctermid
.Nd generate terminal pathname
.Sh SYNOPSIS
.Fd #include <stdio.h>
.Ft char *
.Fn ctermid "char *buf"
.Sh DESCRIPTION
The
.Fn ctermid
function generates a string, that, when used as a pathname, refers to
the current controlling terminal of the calling process.
.Pp
If
.Ar buf
is the
.Dv NULL
pointer, a pointer to a static area is returned.
Otherwise, the pathname is copied into the memory referenced by
.Ar buf .
The argument
.Ar buf
is assumed to be at least
.Dv L_ctermid
(as defined in the include
file
.Aq Pa stdio.h )
bytes long.
.Pp
The current implementation simply returns
.Ql /dev/tty .
.Sh RETURN VALUES
Upon successful completion, a
.Pf non- Dv NULL
pointer is returned.
Otherwise, a
.Dv NULL
pointer is returned and the global variable
.Va errno
is set to indicate the error.
.Sh ERRORS
The current implementation detects no error conditions.
.Sh SEE ALSO
.Xr ttyname 3
.Sh STANDARDS
The
.Xr ctermid
function conforms to
.St -p1003.1-88 .
.Sh BUGS
By default the
.Fn ctermid
function
writes all information to an internal static object.
Subsequent calls to
.Fn ctermid
will modify the same object.