X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/1691e80890e5d8ba258c51c214a3e91880e1db2b..94187a80bd60baab4b9c4b949ad820d730578123:/sbr/done.c diff --git a/sbr/done.c b/sbr/done.c index 02465ea0..5f2bc8db 100644 --- a/sbr/done.c +++ b/sbr/done.c @@ -1,14 +1,32 @@ - -/* - * done.c -- terminate the program +/* done.c -- terminate the program * - * $Id$ + * This code is Copyright (c) 2002, by the authors of nmh. See the + * COPYRIGHT file in the root directory of the nmh distribution for + * complete copyright information. */ #include +static void (*altexit)(int) NORETURN = exit; + +/* set_done changes the path of done() from exit(3), or back to exit(3). + * Anything else will work, but a standard-error warning will report the + * old non-exit() value has been trampled. */ void -done (int status) +set_done(void (*new)(int) NORETURN) +{ + generic_pointer gpo, gpn; + + if (altexit != exit && new != exit) { + gpo.f = (void (*)(void))altexit; + gpn.f = (void (*)(void))new; + inform("altexit trampled: %p %p", gpo.v, gpn.v); + } + altexit = new; +} + +void NORETURN +done(int status) { - exit (status); + (*altexit)(status); }