168 lines
5.5 KiB
HTML
168 lines
5.5 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>perror</title>
|
|
</head>
|
|
<body bgcolor="white">
|
|
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
|
|
</script>
|
|
|
|
<basefont size="3"> <a name="perror"></a> <a name="tag_03_417"></a><!-- perror -->
|
|
<!--header start-->
|
|
<center><font size="2">The Open Group Base Specifications Issue 6<br>
|
|
IEEE Std 1003.1-2001<br>
|
|
Copyright © 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
|
|
|
|
<!--header end-->
|
|
<hr size="2" noshade>
|
|
<h4><a name="tag_03_417_01"></a>NAME</h4>
|
|
|
|
<blockquote>perror - write error messages to standard error</blockquote>
|
|
|
|
<h4><a name="tag_03_417_02"></a>SYNOPSIS</h4>
|
|
|
|
<blockquote class="synopsis">
|
|
<p><code><tt>#include <<a href="../basedefs/stdio.h.html">stdio.h</a>><br>
|
|
<br>
|
|
void perror(const char *</tt><i>s</i><tt>);<br>
|
|
</tt></code></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_417_03"></a>DESCRIPTION</h4>
|
|
|
|
<blockquote>
|
|
<div class="box"><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]"
|
|
border="0"> The functionality described on this reference page is aligned with the ISO C standard. Any conflict between the
|
|
requirements described here and the ISO C standard is unintentional. This volume of IEEE Std 1003.1-2001 defers to
|
|
the ISO C standard. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></div>
|
|
|
|
<p>The <i>perror</i>() function shall map the error number accessed through the symbol <i>errno</i> to a language-dependent error
|
|
message, which shall be written to the standard error stream as follows:</p>
|
|
|
|
<ul>
|
|
<li>
|
|
<p>First (if <i>s</i> is not a null pointer and the character pointed to by <i>s</i> is not the null byte), the string pointed to
|
|
by <i>s</i> followed by a colon and a <space>.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Then an error message string followed by a <newline>.</p>
|
|
</li>
|
|
</ul>
|
|
|
|
<p>The contents of the error message strings shall be the same as those returned by <a href=
|
|
"../functions/strerror.html"><i>strerror</i>()</a> with argument <i>errno</i>.</p>
|
|
|
|
<p><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> The
|
|
<i>perror</i>() function shall mark the file associated with the standard error stream as having been written (<i>st_ctime</i>,
|
|
<i>st_mtime</i> marked for update) at some time between its successful completion and <a href=
|
|
"../functions/exit.html"><i>exit</i>()</a>, <a href="../functions/abort.html"><i>abort</i>()</a>, or the completion of <a href=
|
|
"../functions/fflush.html"><i>fflush</i>()</a> or <a href="../functions/fclose.html"><i>fclose</i>()</a> on <i>stderr</i>. <img
|
|
src="../images/opt-end.gif" alt="[Option End]" border="0"></p>
|
|
|
|
<p>The <i>perror</i>() function shall not change the orientation of the standard error stream.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_417_04"></a>RETURN VALUE</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>perror</i>() function shall not return a value.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_417_05"></a>ERRORS</h4>
|
|
|
|
<blockquote>
|
|
<p>No errors are defined.</p>
|
|
</blockquote>
|
|
|
|
<hr>
|
|
<div class="box"><em>The following sections are informative.</em></div>
|
|
|
|
<h4><a name="tag_03_417_06"></a>EXAMPLES</h4>
|
|
|
|
<blockquote>
|
|
<h5><a name="tag_03_417_06_01"></a>Printing an Error Message for a Function</h5>
|
|
|
|
<p>The following example replaces <i>bufptr</i> with a buffer that is the necessary size. If an error occurs, the <i>perror</i>()
|
|
function prints a message and the program exits.</p>
|
|
|
|
<pre>
|
|
<tt>#include <stdio.h>
|
|
#include <stdlib.h>
|
|
...
|
|
char *bufptr;
|
|
size_t szbuf;
|
|
...
|
|
if ((bufptr = malloc(szbuf)) == NULL) {
|
|
perror("malloc"); exit(2);
|
|
}
|
|
...
|
|
</tt>
|
|
</pre>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_417_07"></a>APPLICATION USAGE</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_417_08"></a>RATIONALE</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_417_09"></a>FUTURE DIRECTIONS</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_417_10"></a>SEE ALSO</h4>
|
|
|
|
<blockquote>
|
|
<p><a href="strerror.html"><i>strerror</i>()</a> , the Base Definitions volume of IEEE Std 1003.1-2001, <a href=
|
|
"../basedefs/stdio.h.html"><i><stdio.h></i></a></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_417_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_417_12"></a>Issue 5</h4>
|
|
|
|
<blockquote>
|
|
<p>A paragraph is added to the DESCRIPTION indicating that <i>perror</i>() does not change the orientation of the standard error
|
|
stream.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_417_13"></a>Issue 6</h4>
|
|
|
|
<blockquote>
|
|
<p>Extensions beyond the ISO C standard are marked.</p>
|
|
</blockquote>
|
|
|
|
<div class="box"><em>End of informative text.</em></div>
|
|
|
|
<hr>
|
|
<hr size="2" noshade>
|
|
<center><font size="2"><!--footer start-->
|
|
UNIX ® is a registered Trademark of The Open Group.<br>
|
|
POSIX ® 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>
|
|
|