1PERROR(P)                  POSIX Programmer's Manual                 PERROR(P)
2
3
4

NAME

6       perror - write error messages to standard error
7

SYNOPSIS

9       #include <stdio.h>
10
11       void perror(const char *s);
12
13

DESCRIPTION

15       The  perror()  function shall map the error number accessed through the
16       symbol errno to a language-dependent  error  message,  which  shall  be
17       written to the standard error stream as follows:
18
19        * First  (if s is not a null pointer and the character pointed to by s
20          is not the null byte), the string pointed to  by  s  followed  by  a
21          colon and a <space>.
22
23        * Then an error message string followed by a <newline>.
24
25       The  contents  of  the error message strings shall be the same as those
26       returned by strerror() with argument errno.
27
28       The perror() function shall mark the file associated with the  standard
29       error  stream  as  having  been  written (st_ctime, st_mtime marked for
30       update) at some time between  its  successful  completion  and  exit(),
31       abort(), or the completion of fflush() or fclose() on stderr.
32
33       The  perror() function shall not change the orientation of the standard
34       error stream.
35

RETURN VALUE

37       The perror() function shall not return a value.
38

ERRORS

40       No errors are defined.
41
42       The following sections are informative.
43

EXAMPLES

45   Printing an Error Message for a Function
46       The following example replaces bufptr with a buffer that is the  necesā€
47       sary  size.  If an error occurs, the perror() function prints a message
48       and the program exits.
49
50
51              #include <stdio.h>
52              #include <stdlib.h>
53              ...
54              char *bufptr;
55              size_t szbuf;
56              ...
57              if ((bufptr = malloc(szbuf)) == NULL) {
58                  perror("malloc"); exit(2);
59              }
60              ...
61

APPLICATION USAGE

63       None.
64

RATIONALE

66       None.
67

FUTURE DIRECTIONS

69       None.
70

SEE ALSO

72       strerror() ,  the  Base  Definitions  volume  of  IEEE Std 1003.1-2001,
73       <stdio.h>
74
76       Portions  of  this text are reprinted and reproduced in electronic form
77       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
78       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
79       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
80       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
81       event of any discrepancy between this version and the original IEEE and
82       The  Open Group Standard, the original IEEE and The Open Group Standard
83       is the referee document. The original Standard can be  obtained  online
84       at http://www.opengroup.org/unix/online.html .
85
86
87
88IEEE/The Open Group                  2003                            PERROR(P)
Impressum