9 extern __noreturn (*__exit_handler
)(int);
10 static struct atexit
*__atexit_list
;
12 static __noreturn
on_exit_exit(int rv
)
16 for ( ap
= __atexit_list
; ap
; ap
= ap
->next
) {
17 ap
->fctn(rv
, ap
->arg
); /* This assumes extra args are harmless */
23 int on_exit(void (*fctn
)(int, void *), void *arg
)
25 struct atexit
*as
= malloc(sizeof(struct atexit
));
33 as
->next
= __atexit_list
;
36 __exit_handler
= on_exit_exit
;