diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 1996-10-09 11:15:13 +0000 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 1996-10-09 11:15:13 +0000 |
commit | 46dddeb68c11d3827748651caa6f17c67b289a07 (patch) | |
tree | 5536a25d9df66b1d22026cc486d9e825dbdfd4cd | |
parent | e4f0480a473cc9b9a801c86d0478f34b32226c5f (diff) |
pervasives: ajout de do_at_exit.
std_exit: appeler do_at_exit mais pas exit (pour permettre le retour
dans du code C)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@1069 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r-- | stdlib/pervasives.ml | 11 | ||||
-rw-r--r-- | stdlib/pervasives.mli | 2 | ||||
-rw-r--r-- | stdlib/std_exit.ml | 4 |
3 files changed, 11 insertions, 6 deletions
diff --git a/stdlib/pervasives.ml b/stdlib/pervasives.ml index eb8aa8e0f..ad1bb2b3b 100644 --- a/stdlib/pervasives.ml +++ b/stdlib/pervasives.ml @@ -293,10 +293,13 @@ external sys_exit : int -> 'a = "sys_exit" let exit_function = ref (fun () -> flush stdout; flush stderr) -let exit retcode = - (!exit_function)(); - sys_exit retcode - let at_exit f = let g = !exit_function in exit_function := (fun () -> f(); g()) + +let do_at_exit () = (!exit_function) () + +let exit retcode = + do_at_exit (); + sys_exit retcode + diff --git a/stdlib/pervasives.mli b/stdlib/pervasives.mli index 3acb81bfb..f2e5fa1fb 100644 --- a/stdlib/pervasives.mli +++ b/stdlib/pervasives.mli @@ -539,3 +539,5 @@ val at_exit: (unit -> unit) -> unit (*** For system use only, not for the casual user *) val unsafe_really_input : in_channel -> string -> int -> int -> unit + +val do_at_exit: unit -> unit diff --git a/stdlib/std_exit.ml b/stdlib/std_exit.ml index 5debeac6d..e53eadfd6 100644 --- a/stdlib/std_exit.ml +++ b/stdlib/std_exit.ml @@ -11,6 +11,6 @@ (* $Id$ *) -(* Ensure that [exit] is called at the end of every program *) +(* Ensure that [at_exit] functions are called at the end of every program *) -let _ = exit 0 +let _ = do_at_exit() |