Files
oldlinux-files/Ref-docs/POSIX/susv3/functions/ttyname.html
2024-02-19 00:21:47 -05:00

191 lines
6.8 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
<title>ttyname</title>
</head>
<body bgcolor="white">
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
</script>
<basefont size="3"> <a name="ttyname"></a> <a name="tag_03_793"></a><!-- ttyname -->
<!--header start-->
<center><font size="2">The Open Group Base Specifications Issue 6<br>
IEEE Std 1003.1-2001<br>
Copyright &copy; 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
<!--header end-->
<hr size="2" noshade>
<h4><a name="tag_03_793_01"></a>NAME</h4>
<blockquote>ttyname, ttyname_r - find the pathname of a terminal</blockquote>
<h4><a name="tag_03_793_02"></a>SYNOPSIS</h4>
<blockquote class="synopsis">
<p><code><tt>#include &lt;<a href="../basedefs/unistd.h.html">unistd.h</a>&gt;<br>
<br>
char *ttyname(int</tt> <i>fildes</i><tt>);<br>
</tt></code></p>
<div class="box"><code><tt><sup>[<a href="javascript:open_code('TSF')">TSF</a>]</sup> <img src="../images/opt-start.gif" alt=
"[Option Start]" border="0"> int ttyname_r(int</tt> <i>fildes</i><tt>, char *</tt><i>name</i><tt>, size_t</tt>
<i>namesize</i><tt>); <img src="../images/opt-end.gif" alt="[Option End]" border="0"></tt></code></div>
<tt><br>
</tt></blockquote>
<h4><a name="tag_03_793_03"></a>DESCRIPTION</h4>
<blockquote>
<p>The <i>ttyname</i>() function shall return a pointer to a string containing a null-terminated pathname of the terminal
associated with file descriptor <i>fildes</i>. The return value may point to static data whose content is overwritten by each
call.</p>
<p>The <i>ttyname</i>() function need not be reentrant. A function that is not required to be reentrant is not required to be
thread-safe.</p>
<p><sup>[<a href="javascript:open_code('TSF')">TSF</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
The <i>ttyname_r</i>() function shall store the null-terminated pathname of the terminal associated with the file descriptor
<i>fildes</i> in the character array referenced by <i>name</i>. The array is <i>namesize</i> characters long and should have space
for the name and the terminating null character. The maximum length of the terminal name shall be {TTY_NAME_MAX}. <img src=
"../images/opt-end.gif" alt="[Option End]" border="0"></p>
</blockquote>
<h4><a name="tag_03_793_04"></a>RETURN VALUE</h4>
<blockquote>
<p>Upon successful completion, <i>ttyname</i>() shall return a pointer to a string. Otherwise, a null pointer shall be returned and
<i>errno</i> set to indicate the error.</p>
<p><sup>[<a href="javascript:open_code('TSF')">TSF</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
If successful, the <i>ttyname_r</i>() function shall return zero. Otherwise, an error number shall be returned to indicate the
error. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p>
</blockquote>
<h4><a name="tag_03_793_05"></a>ERRORS</h4>
<blockquote>
<p>The <i>ttyname</i>() function may fail if:</p>
<dl compact>
<dt>[EBADF]</dt>
<dd>The <i>fildes</i> argument is not a valid file descriptor.</dd>
<dt>[ENOTTY]</dt>
<dd>The <i>fildes</i> argument does not refer to a terminal.</dd>
</dl>
<p>The <i>ttyname_r</i>() function may fail if:</p>
<dl compact>
<dt>[EBADF]</dt>
<dd><sup>[<a href="javascript:open_code('TSF')">TSF</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
The <i>fildes</i> argument is not a valid file descriptor. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd>
<dt>[ENOTTY]</dt>
<dd><sup>[<a href="javascript:open_code('TSF')">TSF</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
The <i>fildes</i> argument does not refer to a terminal. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd>
<dt>[ERANGE]</dt>
<dd><sup>[<a href="javascript:open_code('TSF')">TSF</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
The value of <i>namesize</i> is smaller than the length of the string to be returned including the terminating null character. <img
src="../images/opt-end.gif" alt="[Option End]" border="0"></dd>
</dl>
</blockquote>
<hr>
<div class="box"><em>The following sections are informative.</em></div>
<h4><a name="tag_03_793_06"></a>EXAMPLES</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_03_793_07"></a>APPLICATION USAGE</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_03_793_08"></a>RATIONALE</h4>
<blockquote>
<p>The term ``terminal'' is used instead of the historical term ``terminal device'' in order to avoid a reference to an undefined
term.</p>
<p>The thread-safe version places the terminal name in a user-supplied buffer and returns a non-zero value if it fails. The
non-thread-safe version may return the name in a static data area that may be overwritten by each call.</p>
</blockquote>
<h4><a name="tag_03_793_09"></a>FUTURE DIRECTIONS</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_03_793_10"></a>SEE ALSO</h4>
<blockquote>
<p>The Base Definitions volume of IEEE&nbsp;Std&nbsp;1003.1-2001, <a href=
"../basedefs/unistd.h.html"><i>&lt;unistd.h&gt;</i></a></p>
</blockquote>
<h4><a name="tag_03_793_11"></a>CHANGE HISTORY</h4>
<blockquote>
<p>First released in Issue 1. Derived from Issue 1 of the SVID.</p>
</blockquote>
<h4><a name="tag_03_793_12"></a>Issue 5</h4>
<blockquote>
<p>The <i>ttyname_r</i>() function is included for alignment with the POSIX Threads Extension.</p>
<p>A note indicating that the <i>ttyname</i>() function need not be reentrant is added to the DESCRIPTION.</p>
</blockquote>
<h4><a name="tag_03_793_13"></a>Issue 6</h4>
<blockquote>
<p>The <i>ttyname_r</i>() function is marked as part of the Thread-Safe Functions option.</p>
<p>The following new requirements on POSIX implementations derive from alignment with the Single UNIX Specification:</p>
<ul>
<li>
<p>The statement that <i>errno</i> is set on error is added.</p>
</li>
<li>
<p>The [EBADF] and [ENOTTY] optional error conditions are added.</p>
</li>
</ul>
</blockquote>
<div class="box"><em>End of informative text.</em></div>
<hr>
<hr size="2" noshade>
<center><font size="2"><!--footer start-->
UNIX &reg; is a registered Trademark of The Open Group.<br>
POSIX &reg; is a registered Trademark of The IEEE.<br>
[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
"../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>
]</font></center>
<!--footer end-->
<hr size="2" noshade>
</body>
</html>