err.3 (c879ae3536e6d92b8d96c8965c5b05fcb9541520) | err.3 (46658b2b2e9c11075190dc1e98cbdf557c57bff4) |
---|---|
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. --- 164 unchanged lines hidden (view full) --- 173argument must be either a pointer to an open stream 174(possibly already converted to void *) 175or a null pointer 176(in which case the output stream is set to standard error). 177.Sh EXAMPLES 178Display the current errno information string and exit: 179.Bd -literal -offset indent 180if ((p = malloc(size)) == NULL) | 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. --- 164 unchanged lines hidden (view full) --- 173argument must be either a pointer to an open stream 174(possibly already converted to void *) 175or a null pointer 176(in which case the output stream is set to standard error). 177.Sh EXAMPLES 178Display the current errno information string and exit: 179.Bd -literal -offset indent 180if ((p = malloc(size)) == NULL) |
181 err(1, NULL); | 181 err(EX_OSERR, NULL); |
182if ((fd = open(file_name, O_RDONLY, 0)) == -1) | 182if ((fd = open(file_name, O_RDONLY, 0)) == -1) |
183 err(1, "%s", file_name); | 183 err(EX_NOINPUT, "%s", file_name); |
184.Ed 185.Pp 186Display an error message and exit: 187.Bd -literal -offset indent 188if (tm.tm_hour < START_TIME) | 184.Ed 185.Pp 186Display an error message and exit: 187.Bd -literal -offset indent 188if (tm.tm_hour < START_TIME) |
189 errx(1, "too early, wait until %s", start_time_string); | 189 errx(EX_DATAERR, "too early, wait until %s", 190 start_time_string); |
190.Ed 191.Pp 192Warn of an error: 193.Bd -literal -offset indent 194if ((fd = open(raw_device, O_RDONLY, 0)) == -1) 195 warnx("%s: %s: trying the block device", 196 raw_device, strerror(errno)); 197if ((fd = open(block_device, O_RDONLY, 0)) == -1) | 191.Ed 192.Pp 193Warn of an error: 194.Bd -literal -offset indent 195if ((fd = open(raw_device, O_RDONLY, 0)) == -1) 196 warnx("%s: %s: trying the block device", 197 raw_device, strerror(errno)); 198if ((fd = open(block_device, O_RDONLY, 0)) == -1) |
198 err(1, "%s", block_device); | 199 err(EX_OSFILE, "%s", block_device); |
199.Ed 200.Pp 201Warn of an error without using the global variable 202.Va errno : 203.Bd -literal -offset indent 204error = my_function(); /* returns a value from <errno.h> */ 205if (error != 0) 206 warnc(error, "my_function"); --- 26 unchanged lines hidden --- | 200.Ed 201.Pp 202Warn of an error without using the global variable 203.Va errno : 204.Bd -literal -offset indent 205error = my_function(); /* returns a value from <errno.h> */ 206if (error != 0) 207 warnc(error, "my_function"); --- 26 unchanged lines hidden --- |