err.3 (58f0484fa251c266ede97b591b499fe3dd4f578e) | err.3 (3688be0eeb59367d9dd33e4b0963813b72ce0ef3) |
---|---|
1.\" Copyright (c) 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. --- 15 unchanged lines hidden (view full) --- 24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30.\" SUCH DAMAGE. 31.\" | 1.\" Copyright (c) 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. --- 15 unchanged lines hidden (view full) --- 24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30.\" SUCH DAMAGE. 31.\" |
32.\" @(#)err.3 8.1 (Berkeley) 6/9/93 | 32.\" From: @(#)err.3 8.1 (Berkeley) 6/9/93 33.\" $Id$ |
33.\" | 34.\" |
34.Dd "June 9, 1993" | 35.Dd April 13, 1995 |
35.Dt ERR 3 36.Os BSD 4 37.Sh NAME 38.Nm err , 39.Nm verr , 40.Nm errx , 41.Nm verrx , 42.Nm warn , 43.Nm vwarn , 44.Nm warnx , | 36.Dt ERR 3 37.Os BSD 4 38.Sh NAME 39.Nm err , 40.Nm verr , 41.Nm errx , 42.Nm verrx , 43.Nm warn , 44.Nm vwarn , 45.Nm warnx , |
45.Nm vwarnx | 46.Nm vwarnx , 47.Nm err_set_file , 48.Nm err_set_exit |
46.Nd formatted error messages 47.Sh SYNOPSIS 48.Fd #include <err.h> 49.Ft void 50.Fn err "int eval" "const char *fmt" "..." 51.Ft void 52.Fn verr "int eval" "const char *fmt" "va_list args" 53.Ft void 54.Fn errx "int eval" "const char *fmt" "..." 55.Ft void 56.Fn verrx "int eval" "const char *fmt" "va_list args" 57.Ft void 58.Fn warn "const char *fmt" "..." 59.Ft void 60.Fn vwarn "const char *fmt" "va_list args" 61.Ft void 62.Fn warnx "const char *fmt" "..." 63.Ft void 64.Fn vwarnx "const char *fmt" "va_list args" | 49.Nd formatted error messages 50.Sh SYNOPSIS 51.Fd #include <err.h> 52.Ft void 53.Fn err "int eval" "const char *fmt" "..." 54.Ft void 55.Fn verr "int eval" "const char *fmt" "va_list args" 56.Ft void 57.Fn errx "int eval" "const char *fmt" "..." 58.Ft void 59.Fn verrx "int eval" "const char *fmt" "va_list args" 60.Ft void 61.Fn warn "const char *fmt" "..." 62.Ft void 63.Fn vwarn "const char *fmt" "va_list args" 64.Ft void 65.Fn warnx "const char *fmt" "..." 66.Ft void 67.Fn vwarnx "const char *fmt" "va_list args" |
68.Ft void 69.Fn err_set_file "void *fp" 70.Ft void 71.Fn err_set_exit "void (*exitf)(int)" |
|
65.Sh DESCRIPTION 66The 67.Fn err 68and 69.Fn warn 70family of functions display a formatted error message on the standard | 72.Sh DESCRIPTION 73The 74.Fn err 75and 76.Fn warn 77family of functions display a formatted error message on the standard |
71error output. | 78error output, or on another file specified using the 79.Fn err_set_file 80function. |
72In all cases, the last component of the program name, a colon character, 73and a space are output. 74If the 75.Va fmt 76argument is not NULL, the formatted error message, a colon character, 77and a space are output. 78In the case of the 79.Fn err , --- 10 unchanged lines hidden (view full) --- 90The 91.Fn err , 92.Fn verr , 93.Fn errx , 94and 95.Fn verrx 96functions do not return, but exit with the value of the argument 97.Fa eval . | 81In all cases, the last component of the program name, a colon character, 82and a space are output. 83If the 84.Va fmt 85argument is not NULL, the formatted error message, a colon character, 86and a space are output. 87In the case of the 88.Fn err , --- 10 unchanged lines hidden (view full) --- 99The 100.Fn err , 101.Fn verr , 102.Fn errx , 103and 104.Fn verrx 105functions do not return, but exit with the value of the argument 106.Fa eval . |
107The 108.Fn err_set_exit 109function can be used to specify a function which is called before 110.Xr exit 2 111to perform any necessary cleanup; passing a null function pointer for 112.Va exitf 113resets the hook to do nothing. |
|
98.Sh EXAMPLES 99Display the current errno information string and exit: 100.Bd -literal -offset indent 101if ((p = malloc(size)) == NULL) 102 err(1, NULL); 103if ((fd = open(file_name, O_RDONLY, 0)) == -1) 104 err(1, "%s", file_name); 105.Ed --- 23 unchanged lines hidden --- | 114.Sh EXAMPLES 115Display the current errno information string and exit: 116.Bd -literal -offset indent 117if ((p = malloc(size)) == NULL) 118 err(1, NULL); 119if ((fd = open(file_name, O_RDONLY, 0)) == -1) 120 err(1, "%s", file_name); 121.Ed --- 23 unchanged lines hidden --- |