ERROR

Section: C Library Functions (3)
Updated: local
Index Return to Main Contents
 

NAME

error, warning - print error messages  

SYNOPSIS

error(s1, s2)
char *s1;
char *s2;

warning(s1, s2)
char *s1;
char *s2;

extern char *progname;
extern int errno;

progname = argv[0];
 

DESCRIPTION

Warning prints an error message, with suitable embellishments, and clears errno. Error does likewise and then exits. The s1 argument should be a printf format string (without a trailing newline), with s2 available as an argument.

If there is an environment variable CMDNAME with non-null value, its contents are printed first, followed by a colon. Following this, any non-null value of progname is printed, followed by a colon and a space. Following this, fprintf(3) is invoked with s1 as the format string and s2 as the argument. If the value of errno is within the normal range, a standard elaborating message is printed (see intro(2)).

CMDNAME should be set by shellfiles that expect subordinate programs to issue error message in the shellfile's name. Progname should be set by all programs; argv[0] is usually a suitable thing to set it to. Errno is set by system calls and various other routines, although its use is not universal; note that it is not reset by successful system calls following an unsuccessful one.  

SEE ALSO

intro(2), intro(3), printf(3), exit(2), getopt(3)  

DIAGNOSTICS

Error's exit status is 1.  

HISTORY

Local products, modelled on the error in Kernighan&Pike.  

BUGS

Be nice if they could take a full printf-style argument list.


 

Index

NAME
SYNOPSIS
DESCRIPTION
SEE ALSO
DIAGNOSTICS
HISTORY
BUGS

This document was created by man2html, using the manual pages.
Time: 16:42:33 GMT, November 10, 2022