Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

perror(3p) [centos man page]

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

PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the correspond- ing Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux. NAME
perror - write error messages to standard error SYNOPSIS
#include <stdio.h> void perror(const char *s); DESCRIPTION
The perror() function shall map the error number accessed through the symbol errno 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 strerror() with argument errno. The perror() function shall mark the file associated with the standard error stream as having been written (st_ctime, st_mtime marked for update) at some time between its successful completion and exit(), abort(), or the completion of fflush() or fclose() on stderr. The perror() function shall not change the orientation of the standard error stream. RETURN VALUE
The perror() function shall not return a value. ERRORS
No errors are defined. The following sections are informative. EXAMPLES
Printing an Error Message for a Function The following example replaces bufptr with a buffer that is the necessary size. If an error occurs, the perror() function prints a message and the program exits. #include <stdio.h> #include <stdlib.h> ... char *bufptr; size_t szbuf; ... if ((bufptr = malloc(szbuf)) == NULL) { perror("malloc"); exit(2); } ... APPLICATION USAGE
None. RATIONALE
None. FUTURE DIRECTIONS
None. SEE ALSO
strerror(), the Base Definitions volume of IEEE Std 1003.1-2001, <stdio.h> COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technol- ogy -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. 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.opengroup.org/unix/online.html . IEEE
/The Open Group 2003 PERROR(3P)

Check Out this Related Man Page

STRERROR(3P)						     POSIX Programmer's Manual						      STRERROR(3P)

PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the correspond- ing Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux. NAME
strerror, strerror_r - get error message string SYNOPSIS
#include <string.h> char *strerror(int errnum); int strerror_r(int errnum, char *strerrbuf, size_t buflen); DESCRIPTION
For strerror(): The functionality described on this reference page is aligned with the ISO C standard. Any conflict between the require- ments described here and the ISO C standard is unintentional. This volume of IEEE Std 1003.1-2001 defers to the ISO C standard. The strerror() function shall map the error number in errnum to a locale-dependent error message string and shall return a pointer to it. Typically, the values for errnum come from errno, but strerror() shall map any value of type int to a message. The string pointed to shall not be modified by the application, but may be overwritten by a subsequent call to strerror() or perror(). The contents of the error message strings returned by strerror() should be determined by the setting of the LC_MESSAGES category in the current locale. The implementation shall behave as if no function defined in this volume of IEEE Std 1003.1-2001 calls strerror(). The strerror() function shall not change the setting of errno if successful. Since no return value is reserved to indicate an error, an application wishing to check for error situations should set errno to 0, then call strerror(), then check errno. The strerror() function need not be reentrant. A function that is not required to be reentrant is not required to be thread-safe. The strerror_r() function shall map the error number in errnum to a locale-dependent error message string and shall return the string in the buffer pointed to by strerrbuf, with length buflen. RETURN VALUE
Upon successful completion, strerror() shall return a pointer to the generated message string. On error errno may be set, but no return value is reserved to indicate an error. Upon successful completion, strerror_r() shall return 0. Otherwise, an error number shall be returned to indicate the error. ERRORS
These functions may fail if: EINVAL The value of errnum is not a valid error number. The strerror_r() function may fail if: ERANGE Insufficient storage was supplied via strerrbuf and buflen to contain the generated message string. The following sections are informative. EXAMPLES
None. APPLICATION USAGE
None. RATIONALE
None. FUTURE DIRECTIONS
None. SEE ALSO
perror(), the Base Definitions volume of IEEE Std 1003.1-2001, <string.h> COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technol- ogy -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. 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.opengroup.org/unix/online.html . IEEE
/The Open Group 2003 STRERROR(3P)
Man Page

Featured Tech Videos