


## at-exit.pkg
# Compiled by:
# src/lib/std/src/standard-core.sublib# The (generic) support for the winix::process::atExit function.
# Compiled by:
# src/lib/std/src/standard-core.sublib### "Every exit is an entry somewhere else."
###
### -- Tom Stoppard
api At_Exit {
#
at_exit: (Void -> Void) -> Void;
};
package at_exit
: (weak) At_Exit
{
at_exit_functions
=
REF ([]: List( Void -> Void ) );
# Note that the semantics of atExit require that calls to exit
# in an atExit action cause the remaining atExit actions to be
# performed.
#
fun do_at_exit ()
=
case *at_exit_functions
[] => ();
(f ! r)
=>
{ at_exit_functions := r;
f() except _ = ();
do_at_exit();
};
esac;
# end case
fun at_exit_function at::SHUTDOWN => do_at_exit();
at_exit_function at::SPAWN_TO_DISK => at_exit_functions := [];
at_exit_function _ => ();
end;
# at is from src/lib/std/src/nj/at.pkg my _ =
at::schedule
(
"winix::process",
[at::SHUTDOWN, at::SPAWN_TO_DISK],
at_exit_function
);
fun at_exit at_function
=
at_exit_functions
:=
at_function ! *at_exit_functions;
};
## COPYRIGHT (c) 1997 Bell Labs, Lucent Technologies.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2012,
## released under Gnu Public Licence version 3.


