clarified bash_output_fifo;
authorwenzelm
Sat, 16 Jul 2011 22:17:27 +0200
changeset 43851 f7f8cf0a1536
parent 43850 7f2cbc713344
child 43855 01b13e9a1a7e
clarified bash_output_fifo;
src/Pure/System/isabelle_system.ML
--- a/src/Pure/System/isabelle_system.ML	Sat Jul 16 20:52:41 2011 +0200
+++ b/src/Pure/System/isabelle_system.ML	Sat Jul 16 22:17:27 2011 +0200
@@ -14,7 +14,7 @@
   val with_tmp_file: string -> string -> (Path.T -> 'a) -> 'a
   val with_tmp_dir: string -> (Path.T -> 'a) -> 'a
   val with_tmp_fifo: (Path.T -> 'a) -> 'a
-  val bash_output_stream: string -> (TextIO.instream -> 'a) -> 'a
+  val bash_output_fifo: string -> (Path.T -> 'a) -> 'a
   val bash_output: string -> string * int
   val bash: string -> int
 end;
@@ -87,7 +87,7 @@
   in Exn.release (Exn.capture f path before ignore (try rm_tree path)) end;
 
 
-(* process output stream *)
+(* fifo *)
 
 fun with_tmp_fifo f =
   with_tmp_file "isabelle-fifo-" ""
@@ -96,14 +96,12 @@
         (_, 0) => f path
       | (out, _) => error (perhaps (try (unsuffix "\n")) out)));
 
-fun bash_output_stream script f =
+fun bash_output_fifo script f =
   with_tmp_fifo (fn fifo =>
     uninterruptible (fn restore_attributes => fn () =>
       (case Bash.process (script ^ " > " ^ File.shell_path fifo ^ " &") of
         {rc = 0, terminate, ...} =>
-          Exn.release
-            (Exn.capture (restore_attributes (fn () => File.open_input f fifo)) ()
-              before terminate ())
+          (restore_attributes f fifo handle exn => (terminate (); reraise exn))
       | {output, ...} => error (perhaps (try (unsuffix "\n")) output))) ());
 
 end;