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(), and vwarn() functions append an error message obtained from strerror(3) based on the global variable errno, and that message is preceded by another colon and space โ€” unless the fmt argument is NULL. ๐Ÿ˜Œ
  • the errx() and warnx() functions do not append an error message. nope, not doing it, not today ๐Ÿšซ
  • the err(), verr(), errx(), and verrx() functions do not return, but exit with the value of the argument eval. 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
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms