errmsg(7)

NAME
errmsg - print diagnostics and/or abort program

SYNTAX
#include <libowfat/errmsg.h>
  errmsg_iam("my_program"); // or use argv[0]
  msg("entering phase 1");
  carp("there is a problem, but we'll soldier on");
  die(111,"fatal problem, program will abort");
  msg("failed to open ",filename," as expected");
  carpsys("failed to open ",filename);
  diesys(111,"error opening ",filename,", bailing out");

DESCRIPTION
At the start of the program, call errmsg_iam so the diagnostic messages will include the program name. msg will print to stdout (fd #1), carp will print to stderr (fd #2), die will print to stderr (fd #2) and then exit with the return code you specified. msgsys, carpsys and diesys will also include a string representation of the system error code in errno. By convention, fd #1 is for regular output and fd #2 is for error messages. These message are written directly to the corresponding file descriptor, without buffering. There is no need for flushing.

NOTE
These functions do not synchronize with buffer_1 or buffer_2. If you have pending output in a buffer, you need to flush manually first (see buffer_flush).

SEE ALSO
buffer_flush(3)