Files
riverguile/src/call-exit-handler.c
Leon Henrik Plickat 732c1adb55 add exit handler
2024-01-06 23:55:26 +01:00

30 lines
744 B
C

#include <libguile.h>
#include <assert.h>
#include "riverguile.h"
static void *call_exit_handler_inner (void *data)
{
assert(data == NULL);
return scm_call_0(context.exit_handler);
}
void *call_exit_handler (void)
{
assert(context.exit_handler != NULL);
/* Continuation barrier causes stack unwind on exceptions (i.e. errors
* in the user defined exit handler) to stop here. Otherwise the entire
* stack created by scm_with_guile() would be unwound. This makes
* responding to exceptions nicer.
*/
SCM call_result = scm_c_with_continuation_barrier(
call_exit_handler_inner, NULL
);
if ( call_result == NULL )
return (void *)"ERROR: An exception occured while calling the exit handler.\n";
return NULL;
}