244 lines
5.0 KiB
HTML
244 lines
5.0 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of ERR</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>ERR</H1>
|
|
Section: Linux Programmer's Manual (3)<BR>Updated: 2017-09-15<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
err, verr, errx, verrx, warn, vwarn, warnx, vwarnx - formatted error messages
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<PRE>
|
|
<B>#include <<A HREF="file:///usr/include/err.h">err.h</A>></B>
|
|
|
|
<B>void err(int </B><I>eval</I><B>, const char *</B><I>fmt</I><B>, ...);</B>
|
|
|
|
<B>void errx(int </B><I>eval</I><B>, const char *</B><I>fmt</I><B>, ...);</B>
|
|
|
|
<B>void warn(const char *</B><I>fmt</I><B>, ...);</B>
|
|
|
|
<B>void warnx(const char *</B><I>fmt</I><B>, ...);</B>
|
|
|
|
<B>#include <<A HREF="file:///usr/include/stdarg.h">stdarg.h</A>></B>
|
|
|
|
<B>void verr(int </B><I>eval</I><B>, const char *</B><I>fmt</I><B>, va_list </B><I>args</I><B>);</B>
|
|
|
|
<B>void verrx(int </B><I>eval</I><B>, const char *</B><I>fmt</I><B>, va_list </B><I>args</I><B>);</B>
|
|
|
|
<B>void vwarn(const char *</B><I>fmt</I><B>, va_list </B><I>args</I><B>);</B>
|
|
|
|
<B>void vwarnx(const char *</B><I>fmt</I><B>, va_list </B><I>args</I><B>);</B>
|
|
</PRE>
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
The
|
|
<B>err</B>()
|
|
|
|
and
|
|
<B>warn</B>()
|
|
|
|
family of functions display a formatted error message on the standard
|
|
error output.
|
|
In all cases, the last component of the program name, a colon character,
|
|
and a space are output.
|
|
If the
|
|
<I>fmt</I>
|
|
|
|
argument is not NULL, the
|
|
<B><A HREF="/cgi-bin/man/man2html?3+printf">printf</A></B>(3)-like
|
|
|
|
formatted error message is output.
|
|
The output is terminated by a newline character.
|
|
<P>
|
|
|
|
The
|
|
<B>err</B>(),
|
|
|
|
<B>verr</B>(),
|
|
|
|
<B>warn</B>(),
|
|
|
|
and
|
|
<B>vwarn</B>()
|
|
|
|
functions append an error message obtained from
|
|
<B><A HREF="/cgi-bin/man/man2html?3+strerror">strerror</A></B>(3)
|
|
|
|
based on the global variable
|
|
<I>errno</I>,
|
|
|
|
preceded by another colon and space unless the
|
|
<I>fmt</I>
|
|
|
|
argument is
|
|
NULL.
|
|
<P>
|
|
|
|
The
|
|
<B>errx</B>()
|
|
|
|
and
|
|
<B>warnx</B>()
|
|
|
|
functions do not append an error message.
|
|
<P>
|
|
|
|
The
|
|
<B>err</B>(),
|
|
|
|
<B>verr</B>(),
|
|
|
|
<B>errx</B>(),
|
|
|
|
and
|
|
<B>verrx</B>()
|
|
|
|
functions do not return, but exit with the value of the argument
|
|
<I>eval</I>.
|
|
|
|
<A NAME="lbAE"> </A>
|
|
<H2>ATTRIBUTES</H2>
|
|
|
|
For an explanation of the terms used in this section, see
|
|
<B><A HREF="/cgi-bin/man/man2html?7+attributes">attributes</A></B>(7).
|
|
|
|
<TABLE BORDER>
|
|
<TR VALIGN=top><TD><B>Interface</B></TD><TD><B>Attribute</B></TD><TD><B>Value</B><BR></TD></TR>
|
|
<TR VALIGN=top><TD>
|
|
<B>err</B>(),
|
|
|
|
<B>errx</B>(),
|
|
|
|
<BR>
|
|
|
|
<B>warn</B>(),
|
|
|
|
<B>warnx</B>(),
|
|
|
|
<BR>
|
|
|
|
<B>verr</B>(),
|
|
|
|
<B>verrx</B>(),
|
|
|
|
<BR>
|
|
|
|
<B>vwarn</B>(),
|
|
|
|
<B>vwarnx</B>()
|
|
|
|
</TD><TD>Thread safety</TD><TD>MT-Safe locale<BR></TD></TR>
|
|
</TABLE>
|
|
|
|
<P>
|
|
<A NAME="lbAF"> </A>
|
|
<H2>CONFORMING TO</H2>
|
|
|
|
These functions are nonstandard BSD extensions.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<A NAME="lbAG"> </A>
|
|
<H2>EXAMPLE</H2>
|
|
|
|
Display the current
|
|
<I>errno</I>
|
|
|
|
information string and exit:
|
|
<P>
|
|
|
|
|
|
|
|
p = malloc(size);
|
|
if (p == NULL)
|
|
<BR> err(1, NULL);
|
|
fd = open(file_name, O_RDONLY, 0);
|
|
if (fd == -1)
|
|
<BR> err(1, "%s", file_name);
|
|
|
|
|
|
<P>
|
|
|
|
Display an error message and exit:
|
|
<P>
|
|
|
|
|
|
|
|
if (tm.tm_hour < START_TIME)
|
|
<BR> errx(1, "too early, wait until %s", start_time_string);
|
|
|
|
|
|
<P>
|
|
|
|
Warn of an error:
|
|
<P>
|
|
|
|
|
|
|
|
fd = open(raw_device, O_RDONLY, 0);
|
|
if (fd == -1)
|
|
<BR> warnx("%s: %s: trying the block device",
|
|
<BR> raw_device, strerror(errno));
|
|
fd = open(block_device, O_RDONLY, 0);
|
|
if (fd == -1)
|
|
<BR> err(1, "%s", block_device);
|
|
|
|
|
|
<A NAME="lbAH"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+error">error</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+exit">exit</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+perror">perror</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+printf">printf</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+strerror">strerror</A></B>(3)
|
|
|
|
<A NAME="lbAI"> </A>
|
|
<H2>COLOPHON</H2>
|
|
|
|
This page is part of release 5.05 of the Linux
|
|
<I>man-pages</I>
|
|
|
|
project.
|
|
A description of the project,
|
|
information about reporting bugs,
|
|
and the latest version of this page,
|
|
can be found at
|
|
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="1"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="2"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="3"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="4"><A HREF="#lbAE">ATTRIBUTES</A><DD>
|
|
<DT id="5"><A HREF="#lbAF">CONFORMING TO</A><DD>
|
|
<DT id="6"><A HREF="#lbAG">EXAMPLE</A><DD>
|
|
<DT id="7"><A HREF="#lbAH">SEE ALSO</A><DD>
|
|
<DT id="8"><A HREF="#lbAI">COLOPHON</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:39 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|