src/Pure/System/command_line.ML
author wenzelm
Mon Jul 15 10:25:35 2013 +0200 (2013-07-15 ago)
changeset 52655 3b2b1ef13979
parent 51312 0ce544fbb509
child 52686 f4871fe80410
permissions -rw-r--r--
more careful termination of removed execs, leaving running execs undisturbed;
wenzelm@48681
     1
(*  Title:      Pure/System/command_line.ML
wenzelm@48681
     2
    Author:     Makarius
wenzelm@48681
     3
wenzelm@48681
     4
Support for Isabelle/ML command line tools.
wenzelm@48681
     5
*)
wenzelm@48681
     6
wenzelm@48681
     7
signature COMMAND_LINE =
wenzelm@48681
     8
sig
wenzelm@48731
     9
  val tool: (unit -> int) -> unit
wenzelm@51312
    10
  val tool0: (unit -> unit) -> unit
wenzelm@48681
    11
end;
wenzelm@48681
    12
wenzelm@48681
    13
structure Command_Line: COMMAND_LINE =
wenzelm@48681
    14
struct
wenzelm@48681
    15
wenzelm@48681
    16
fun tool body =
wenzelm@48681
    17
  uninterruptible (fn restore_attributes => fn () =>
wenzelm@48681
    18
    let val rc =
wenzelm@48681
    19
      restore_attributes body () handle exn =>
wenzelm@48681
    20
        (Output.error_msg (ML_Compiler.exn_message exn); if Exn.is_interrupt exn then 130 else 1);
wenzelm@48731
    21
    in if rc = 0 then () else exit rc end) ();
wenzelm@48681
    22
wenzelm@51312
    23
fun tool0 body = tool (fn () => (body (); 0));
wenzelm@51312
    24
wenzelm@48681
    25
end;
wenzelm@48681
    26