err(3)
๐ธ NAME ๐ธ
okay so bestie, gather round, this is the err(3) page from the Library Functions Manual ๐ and it's all about formatted error messages, no cap.
err,verr,errx,verrx,warn,vwarn,warnx,vwarnxโ formatted error messages โจ
๐ LIBRARY ๐
Standard C library (libc, -lc) โ it's giving classic, it's giving foundational, it's literally the C library ๐
๐ SYNOPSIS ๐
#include <err.h>
[[noreturn]] void err(int eval, const char *fmt, ...);
[[noreturn]] void errx(int eval, const char *fmt, ...);
void warn(const char *fmt, ...);
void warnx(const char *fmt, ...);
#include <stdarg.h>
[[noreturn]] void verr(int eval, const char *fmt, va_list args);
[[noreturn]] void verrx(int eval, const char *fmt, va_list args);
void vwarn(const char *fmt, va_list args);
void vwarnx(const char *fmt, va_list args);
๐ DESCRIPTION ๐
so the err() and warn() family of functions are the ones that display a formatted error message on the standard error output. every single time, no exceptions, they print the last component of the program name, then a colon character, then a space. then, if the fmt argument is not NULL, they output the printf(3)-like formatted error message. and then the output is terminated by a newline character. slay ๐
- the
err(),verr(),warn(), andvwarn()functions append an error message obtained fromstrerror(3)based on the global variableerrno, and that message is preceded by another colon and space โ unless thefmtargument isNULL. ๐ - the
errx()andwarnx()functions do not append an error message. nope, not doing it, not today ๐ซ - the
err(),verr(),errx(), andverrx()functions do not return, but exit with the value of the argumenteval. like, they're gone, they left the chat, periodt ๐
โจ ATTRIBUTES โจ
for an explanation of the terms used in this section, see attributes(7). here's the vibe check on thread safety, bestie:
- Interface:
err(),errx(),warn(),warnx(),verr(),verrx(),vwarn(),vwarnx() - Attribute: Thread safety
- Value:
MT-Safe locale
๐ STANDARDS ๐
BSD. iconic behaviour honestly ๐ซถ
๐ฆ HISTORY ๐ฆ
err()warn()โ4.4BSD
๐ EXAMPLES ๐
Display the current errno information string and exit:
p = malloc(size);
if (p == NULL)
err(EXIT_FAILURE, NULL);
fd = open(file_name, O_RDONLY, 0);
if (fd == -1)
err(EXIT_FAILURE, "%s", file_name);
Display an error message and exit:
if (tm.tm_hour < START_TIME)
errx(EXIT_FAILURE, "too early, wait until %s",
start_time_string);
Warn of an error:
fd = open(raw_device, O_RDONLY, 0);
if (fd == -1)
warnx("%s: %s: trying the block device",
raw_device, strerror(errno));
fd = open(block_device, O_RDONLY, 0);
if (fd == -1)
err(EXIT_FAILURE, "%s", block_device);
๐ SEE ALSO ๐
and that's the whole page bestie, you ate that ๐ง๐
this was err(3) from Linux man-pages 6.20, dated 2025-05-17 โ go forth and print pretty errors, ily ๐ธ๐ฆ๐
๐ฆ where this page comes from
- arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- ๐ the page's license: BSD-4-Clause-UC
- Copyright 1993, The Regents of the University of California
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms