author | wenzelm |
Mon, 07 Mar 2016 18:20:22 +0100 | |
changeset 62545 | 8ebffdaf2ce2 |
parent 62309 | 96c9a259d275 |
child 62548 | f8ebb715e06d |
permissions | -rw-r--r-- |
43283 | 1 |
/* Title: Pure/System/isabelle_process.scala |
27949
6eb0327c0b9b
Isabelle process management -- always reactive due to multi-threaded I/O.
wenzelm
parents:
diff
changeset
|
2 |
Author: Makarius |
6eb0327c0b9b
Isabelle process management -- always reactive due to multi-threaded I/O.
wenzelm
parents:
diff
changeset
|
3 |
|
57916 | 4 |
Isabelle process wrapper. |
27949
6eb0327c0b9b
Isabelle process management -- always reactive due to multi-threaded I/O.
wenzelm
parents:
diff
changeset
|
5 |
*/ |
6eb0327c0b9b
Isabelle process management -- always reactive due to multi-threaded I/O.
wenzelm
parents:
diff
changeset
|
6 |
|
6eb0327c0b9b
Isabelle process management -- always reactive due to multi-threaded I/O.
wenzelm
parents:
diff
changeset
|
7 |
package isabelle |
6eb0327c0b9b
Isabelle process management -- always reactive due to multi-threaded I/O.
wenzelm
parents:
diff
changeset
|
8 |
|
55618 | 9 |
|
57917 | 10 |
object Isabelle_Process |
11 |
{ |
|
12 |
def apply( |
|
13 |
receiver: Prover.Message => Unit = Console.println(_), |
|
62545
8ebffdaf2ce2
Bash.process always uses a closed script instead of an open argument list, for extra robustness on Windows, where quoting is not well-defined;
wenzelm
parents:
62309
diff
changeset
|
14 |
prover_args: List[String] = Nil): Isabelle_Process = |
57917 | 15 |
{ |
16 |
val system_channel = System_Channel() |
|
17 |
val system_process = |
|
57916 | 18 |
try { |
62545
8ebffdaf2ce2
Bash.process always uses a closed script instead of an open argument list, for extra robustness on Windows, where quoting is not well-defined;
wenzelm
parents:
62309
diff
changeset
|
19 |
val process = |
8ebffdaf2ce2
Bash.process always uses a closed script instead of an open argument list, for extra robustness on Windows, where quoting is not well-defined;
wenzelm
parents:
62309
diff
changeset
|
20 |
Bash.process("\"$ISABELLE_PROCESS\" -P " + File.bash_escape(system_channel.server_name) + |
8ebffdaf2ce2
Bash.process always uses a closed script instead of an open argument list, for extra robustness on Windows, where quoting is not well-defined;
wenzelm
parents:
62309
diff
changeset
|
21 |
" " + File.bash_escape(prover_args)) |
57916 | 22 |
process.stdin.close |
23 |
process |
|
24 |
} |
|
60215 | 25 |
catch { case exn @ ERROR(_) => system_channel.accepted(); throw exn } |
57917 | 26 |
|
27 |
new Isabelle_Process(receiver, system_channel, system_process) |
|
28 |
} |
|
57916 | 29 |
} |
27949
6eb0327c0b9b
Isabelle process management -- always reactive due to multi-threaded I/O.
wenzelm
parents:
diff
changeset
|
30 |
|
57917 | 31 |
class Isabelle_Process private( |
32 |
receiver: Prover.Message => Unit, |
|
33 |
system_channel: System_Channel, |
|
34 |
system_process: Prover.System_Process) |
|
35 |
extends Prover(receiver, system_channel, system_process) |
|
62309 | 36 |
{ |
37 |
def encode(s: String): String = Symbol.encode(s) |
|
38 |
def decode(s: String): String = Symbol.decode(s) |
|
39 |
} |