COMERR(3)

πŸ“¦
version 2022.10.16 Β· 2 versions
, in opensuse-leap 16.0

πŸ’… COMERR(3) β€” or, as the girls call it, SchilyΒ΄s LIBRARY FUNCTIONS πŸŽ€

okay so bestie, buckle in, because comerr() is that friend who never just says "it's fine" β€” she says her whole piece and then leaves the party. literally.


✨ NAME ✨

comerr() β€” prints error message and exits 🌸


πŸ¦‹ SYNOPSIS πŸ¦‹

comerr(format,arg1,...,argn)
char *format;

πŸ’– DESCRIPTION πŸ’–

comerr() formats and prints a message on the error output stream. 🫢

Part of the message is the last error encountered by the system while executing the process. and here's the main character behaviour: comerr() begins its output with the current program name (as passed to it by exec()) followed by a colon ":" and the detailed system error message. then it formats the user supplied format string and arguments in the form printf() would. no cap, she's doing the absolute most and honestly? we love her for it. πŸ‘‘


🌈 RETURNS 🌈

none πŸ’€

Rather than return, comerr() terminates the current process and exits with the system error number as the exit code. so like... she does not come back. she's gone. periodt.


πŸ“ EXAMPLES πŸ“

if (( f = fileopen("file", "r")) == NULL)
     comerr("Cannot open file.\n");

On stderr it appears as:

prog_name: No such file or directory. Cannot open file.

see how the program name showed up first, then a colon, then the system's whole rant, and then your cute little format string? that's the vibe. ✨


πŸ”₯ SEE ALSO πŸ”₯

comerrno(3), error(3), errmsg(3), error(3), geterrno(3), printf(3), format(3)

(and yes, error(3) is literally listed twice β€” she said what she said, iykyk πŸ’…)


πŸ™ˆ NOTES πŸ™ˆ

comerr() attempts to find a line in the message file that corresponds to the system error number. If none can be found, or it has trouble finding or reading the file, it simply says: error #.

so like, no dramatic mystery text, no guessing β€” just error # and she moves on. lowkey respectful of your time. 🧚


and that's the whole page, bestie β€” she formats, she blames the system, she exits, she does not text back. 🌸

β€” brought to you by Joerg Schilling, dated 2022/09/09, living under the COMERR(3) banner inside SchilyΒ΄s LIBRARY FUNCTIONS, mwah πŸ’œ

πŸ“¦ where this page comes from