X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/56a805299de35d8924969138aef4d0f1580daa6d..4aca08ce404ffaa63000c218e8e042d7b27fbfcc:/sbr/done.c diff --git a/sbr/done.c b/sbr/done.c index bcc258cc..8b197b25 100644 --- a/sbr/done.c +++ b/sbr/done.c @@ -1,21 +1,33 @@ - -/* - * done.c -- terminate the program - * - * $Id$ +/* done.c -- terminate the program * * 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 +#include "h/mh.h" +#include "error.h" + +static void (*altexit)(int) NORETURN = exit; -int (*done) (int) = default_done; +/* 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 +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; +} -int -default_done (int status) +void NORETURN +done(int status) { - exit (status); - return 1; /* dead code to satisfy the compiler */ + (*altexit)(status); }