explain_exit(3)
πΈ explain_exit β from the libexplain manual, section 3 β¨
okay bestie, pull up a chair, because this one is short but it is so useful. it's explain_exit(3) from the Library Functions Manual, and it's giving "tell me why my program died before it dies" energy. π
π NAME π
explain_exit β print an explanation of exit status before exiting
like, literally the name says it all. it explains, and then it exits. iconic behaviour.
β¨ SYNOPSIS β¨
#include <libexplain/libexplain.h>
void explain_exit_on_exit(void);
void explain_exit_on_error(void);
void explain_exit_cancel(void);
three little functions, zero arguments, all void. no notes. π
π¦ DESCRIPTION π¦
so here's the tea. the explain_exit_on_exit function may be used to have the calling program print an explanation of its exit status β that's the value you passed to exit(3), or the return value from main β right before it terminates. immediately before. like, last-breath confession vibes. π
the explain_exit_on_error function may be used to have the calling program print an explanation of its exit status immediately before it terminates, if that exit status is not EXIT_SUCCESS. so if everything went fine, it stays quiet. no drama. but the second something goes wrong? it speaks. π₯
the explain_exit_cancel function may be used to cancel the effect of the explain_exit_on_exit or explain_exit_on_error function. changed your mind, bestie, and that's valid.
these functions may be called multiple times, and in any order. the last called has precedence. and the explanation will never be printed more than once β so don't worry about it spamming your terminal, it is not that kind of girl. π
π§ Call Exit As Normal
in order to have the explanation printed, simply call exit(3) as normal, or return from main as normal.
not me needing to say this but: do not call any of these functions in order to exit your program. they are called before you exit your program. they are setup, not the exit itself. do not use them as your exit. periodt. π
π Caveat
this functionality is only available on systems with the on_exit(3) system call. π«Ά
unfortunately, the atexit(3) system call is not sufficiently capable, as it does not pass the exit status to the registered function. it's just not built for this. we don't make the rules. π
β SEE ALSO β
exit(3)β cause normal process terminationatexit(3)β register a function to be called at normal process terminationon_exit(3)β register a function to be called at normal process termination
iykyk, go read those next. π
π COPYRIGHT π
libexplain version 1.4 Copyright (C) 2009 Peter Miller
π AUTHOR π
Written by Peter Miller <pmiller@opensource.org.au>
and that's the whole page, bestie! π this one comes to you from libexplain version 1.4, and the footer just says explain_exit(3) one more time for the road, like a little goodbye wave. no date on this one, so we keep it mysterious. slay, bye! πβ¨
π¦ where this page comes from
- debian bookworm: libexplain-dev 1.4.D001-12+b1 Β· LGPL-3.0-or-later
- debian trixie: libexplain-dev 1.4.D001-16 Β· LGPL-3.0-or-later
- ubuntu jammy: libexplain-dev 1.4.D001-12 Β· LGPL-3.0-or-later
- ubuntu noble: libexplain-dev 1.4.D001-13 Β· LGPL-3.0-or-later
- ubuntu resolute: libexplain-dev 1.4.D001-16 Β· LGPL-3.0-or-later
- Copyright (C) 2009-2011 Peter Miller
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms