Skip to content
Browse files

don't use 'exit' command in the middle of the code, as it is not hand…

…le by the main exception callback (and thus it won't release the lock)
  • Loading branch information...
1 parent 3a8d4b7 commit 27c25492ae9cb55e3ed8c593c1b1f2e6441cd1c2 @samoht samoht committed May 25, 2012
Showing with 10 additions and 8 deletions.
  1. +1 −1 src/client.ml
  2. +4 −2 src/globals.ml
  3. +4 −4 src/opam.ml
  4. +1 −1 src/process.ml
View
2 src/client.ml
@@ -727,7 +727,7 @@ let install name =
"Package %s is already installed (current version is %s)\n"
(N.to_string name)
(V.to_string (V.Set.choose_one (N.Map.find name map_installed)));
- exit 0
+ Globals.exit 1
);
let map_installed =
View
6 src/globals.ml
@@ -53,14 +53,16 @@ let warning fmt =
Printf.eprintf "[%d] WARNING: %s\n%!" (Unix.getpid ()) str
) fmt
-exception Error
+exception Exit of int
let error_and_exit fmt =
Printf.kprintf (fun str ->
error "%s" str;
- raise Error
+ raise (Exit 66)
) fmt
+let exit i = raise (Exit i)
+
let msg fmt =
Printf.kprintf (fun str ->
Printf.printf "%s%!" str
View
8 src/opam.ml
@@ -298,15 +298,15 @@ let () =
List.iter SubCommand.register commands;
try ArgExt.parse global_args
with e ->
- Globals.error "'%s' failed" (String.concat " " (Array.to_list Sys.argv));
+ Globals.msg " '%s' failed\n" (String.concat " " (Array.to_list Sys.argv));
match e with
| Bad (cmd, msg) ->
ArgExt.pp_print_help (ArgExt.SubCommand cmd) Format.err_formatter global_args ();
- Globals.error "%s" msg;
+ Globals.msg "%s\n" msg;
exit 1;
| Failure ("no subcommand defined" as s) ->
ArgExt.pp_print_help ArgExt.NoSubCommand Format.err_formatter global_args ();
- Globals.error "%s" s;
+ Globals.msg "%s\n" s;
exit 2
- | Globals.Error -> exit 3
+ | Globals.Exit i -> exit i
| e -> raise e
View
2 src/process.ml
@@ -109,7 +109,7 @@ let wait p =
iter ()
with e ->
Printf.printf "Exception %s in waitpid\n%!" (Printexc.to_string e);
- exit 2
+ raise (Globals.Exit 2)
let output_lines oc lines =
List.iter (fun line ->

0 comments on commit 27c2549

Please sign in to comment.
Something went wrong with that request. Please try again.