src/Pure/System/command_line.ML
changeset 71656 3e121f999120
parent 71632 c1bc38327bc2
child 78671 66e7a3131fe3
equal deleted inserted replaced
71655:dad29591645a 71656:3e121f999120
     4 Support for Isabelle/ML command line tools.
     4 Support for Isabelle/ML command line tools.
     5 *)
     5 *)
     6 
     6 
     7 signature COMMAND_LINE =
     7 signature COMMAND_LINE =
     8 sig
     8 sig
     9   exception EXIT of int
       
    10   val tool: (unit -> unit) -> unit
     9   val tool: (unit -> unit) -> unit
    11 end;
    10 end;
    12 
    11 
    13 structure Command_Line: COMMAND_LINE =
    12 structure Command_Line: COMMAND_LINE =
    14 struct
    13 struct
    15 
    14 
    16 exception EXIT of int;
       
    17 
       
    18 fun tool body =
    15 fun tool body =
    19   Thread_Attributes.uninterruptible (fn restore_attributes => fn () =>
    16   Thread_Attributes.uninterruptible (fn restore_attributes => fn () =>
    20     let
    17     let
    21       val rc =
    18       val rc =
    22         (restore_attributes body (); 0)
    19         (restore_attributes body (); 0)
    23           handle EXIT rc => rc
    20           handle exn => Exn.capture_exit 2 (fn () => (Runtime.exn_error_message exn; raise exn)) ();
    24             | exn => Exn.capture_exit 2 (fn () => (Runtime.exn_error_message exn; raise exn)) ();
       
    25     in exit rc end) ();
    21     in exit rc end) ();
    26 
    22 
    27 end;
    23 end;