1(* Title: Pure/System/command_line.ML 2 Author: Makarius 3 4Support for Isabelle/ML command line tools. 5*) 6 7signature COMMAND_LINE = 8sig 9 val tool: (unit -> int) -> unit 10 val tool0: (unit -> unit) -> unit 11end; 12 13structure Command_Line: COMMAND_LINE = 14struct 15 16fun tool body = 17 Thread_Attributes.uninterruptible (fn restore_attributes => fn () => 18 let 19 val rc = 20 restore_attributes body () handle exn => 21 Exn.capture_exit 2 (fn () => (Runtime.exn_error_message exn; raise exn)) (); 22 in exit rc end) (); 23 24fun tool0 body = tool (fn () => (body (); 0)); 25 26end; 27 28