PERROR(3)                  POSIX Programmer's Manual                 PERROR(3)



PPRROOLLOOGG
       This manual page is part of the POSIX Programmer's Manual.  The OS
       implementation of this interface may differ (consult the corresponding
       OS manual page for details of OS behavior), or the interface may not be
       implemented on OS.


NNAAMMEE
       perror -- write error messages to standard error

SSYYNNOOPPSSIISS
       #include <stdio.h>

       void perror(const char *_s);

DDEESSCCRRIIPPTTIIOONN
       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 POSIX.1-2008
       defers to the ISO C standard.

       The _p_e_r_r_o_r() function shall map the error number accessed through the
       symbol _e_r_r_n_o to a language-dependent error message, which shall be
       written to the standard error stream as follows:

        *  First (if _s is not a null pointer and the character pointed to by _s
           is not the null byte), the string pointed to by _s followed by a
           <colon> and a <space>.

        *  Then an error message string followed by a <newline>.

       The contents of the error message strings shall be the same as those
       returned by _s_t_r_e_r_r_o_r() with argument _e_r_r_n_o.

       The _p_e_r_r_o_r() function shall mark for update the last data modification
       and last file status change timestamps of the file associated with the
       standard error stream at some time between its successful completion
       and _e_x_i_t(), _a_b_o_r_t(), or the completion of _f_f_l_u_s_h() or _f_c_l_o_s_e() on
       _s_t_d_e_r_r.

       The _p_e_r_r_o_r() function shall not change the orientation of the standard
       error stream.

       On error, _p_e_r_r_o_r() shall set the error indicator for the stream to
       which _s_t_d_e_r_r points, and shall set _e_r_r_n_o to indicate the error.

       Since no value is returned, an application wishing to check for error
       situations should call _c_l_e_a_r_e_r_r(_s_t_d_e_r_r) before calling _p_e_r_r_o_r(), then
       if _f_e_r_r_o_r(_s_t_d_e_r_r) returns non-zero, the value of _e_r_r_n_o indicates which
       error occurred.

RREETTUURRNN VVAALLUUEE
       The _p_e_r_r_o_r() function shall not return a value.

EERRRROORRSS
       Refer to _f_p_u_t_c().

       _T_h_e _f_o_l_l_o_w_i_n_g _s_e_c_t_i_o_n_s _a_r_e _i_n_f_o_r_m_a_t_i_v_e_.

EEXXAAMMPPLLEESS
   PPrriinnttiinngg aann EErrrroorr MMeessssaaggee ffoorr aa FFuunnccttiioonn
       The following example replaces _b_u_f_p_t_r with a buffer that is the
       necessary size. If an error occurs, the _p_e_r_r_o_r() function prints a
       message and the program exits.

           ##iinncclluuddee <<ssttddiioo..hh>>
           ##iinncclluuddee <<ssttddlliibb..hh>>
           ......
           cchhaarr **bbuuffppttrr;;
           ssiizzee__tt sszzbbuuff;;
           ......
           iiff ((((bbuuffppttrr == mmaalllloocc((sszzbbuuff)))) ==== NNUULLLL)) {{
               ppeerrrroorr((""mmaalllloocc""));; eexxiitt((22));;
           }}
           ......

AAPPPPLLIICCAATTIIOONN UUSSAAGGEE
       Application writers may prefer to use alternative interfaces instead of
       _p_e_r_r_o_r(), such as _s_t_r_e_r_r_o_r___r() in combination with _f_p_r_i_n_t_f().

RRAATTIIOONNAALLEE
       None.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       None.

SSEEEE AALLSSOO
       _f_p_r_i_n_t_f(), _f_p_u_t_c(), _p_s_i_g_i_n_f_o(), _s_t_r_e_r_r_o_r()

       The Base Definitions volume of POSIX.1-2008, <<ssttddiioo..hh>>

CCOOPPYYRRIIGGHHTT
       Portions of this text are reprinted and reproduced in electronic form
       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
       -- Portable Operating System Interface (POSIX), The Open Group Base
       Specifications Issue 7, Copyright (C) 2013 by the Institute of
       Electrical and Electronics Engineers, Inc and The Open Group.  (This is
       POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
       event of any discrepancy between this version and the original IEEE and
       The Open Group Standard, the original IEEE and The Open Group Standard
       is the referee document. The original Standard can be obtained online
       at http://www.unix.org/online.html .

       Any typographical or formatting errors that appear in this page are
       most likely to have been introduced during the conversion of the source
       files to man page format. To report such errors, see
       https://www.kernel.org/doc/man-pages/reporting_bugs.html .



IEEE/The Open Group                  2013                            PERROR(3)
