equal
deleted
inserted
replaced
113 open Bash; |
113 open Bash; |
114 |
114 |
115 val string = Bash_Syntax.string; |
115 val string = Bash_Syntax.string; |
116 val strings = Bash_Syntax.strings; |
116 val strings = Bash_Syntax.strings; |
117 |
117 |
118 val process = Thread_Attributes.uninterruptible (fn restore_attributes => fn script => |
118 val process_ml = Thread_Attributes.uninterruptible (fn restore_attributes => fn script => |
119 let |
119 let |
120 datatype result = Wait | Signal | Result of int; |
120 datatype result = Wait | Signal | Result of int; |
121 val result = Synchronized.var "bash_result" Wait; |
121 val result = Synchronized.var "bash_result" Wait; |
122 |
122 |
123 val id = serial_string (); |
123 val id = serial_string (); |
181 val _ = cleanup (); |
181 val _ = cleanup (); |
182 in {out = out, err = err, rc = rc, terminate = fn () => terminate pid} end |
182 in {out = out, err = err, rc = rc, terminate = fn () => terminate pid} end |
183 handle exn => (terminate (read_pid 10); cleanup (); Exn.reraise exn) |
183 handle exn => (terminate (read_pid 10); cleanup (); Exn.reraise exn) |
184 end); |
184 end); |
185 |
185 |
|
186 fun process_scala script = |
|
187 Scala.function "bash_process" script |
|
188 |> YXML.parse_body |
|
189 |> |
|
190 let open XML.Decode in |
|
191 variant |
|
192 [fn ([], []) => raise Exn.Interrupt, |
|
193 fn ([a], []) => error a, |
|
194 fn ([a, b], c) => |
|
195 let |
|
196 val rc = int_atom a; |
|
197 val pid = int_atom b; |
|
198 val (out, err) = pair string string c; |
|
199 in {out = out, err = err, rc = rc, terminate = fn () => terminate (SOME pid)} end] |
|
200 end; |
|
201 |
|
202 fun process script = |
|
203 if ML_System.platform_is_rosetta () then process_scala script else process_ml script; |
|
204 |
186 end; |
205 end; |
187 \<close> |
206 \<close> |