]> diplodocus.org Git - nmh/blobdiff - sbr/done.c
m_backup.c: Move interface to own file.
[nmh] / sbr / done.c
index c703aba5b654e42983cf987b1c310b544bc935a6..8b197b256db4799ac924d83e9f8dba4b7808ace6 100644 (file)
@@ -5,6 +5,29 @@
  * complete copyright information.
  */
 
-#include <h/mh.h>
+#include "h/mh.h"
+#include "error.h"
 
-void (*done) (int) NORETURN = exit;
+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
+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)
+{
+    (*altexit)(status);
+}