equal
deleted
inserted
replaced
52 else Result (256 + LargeWord.toInt (Posix.Signal.toWord s)) |
52 else Result (256 + LargeWord.toInt (Posix.Signal.toWord s)) |
53 | Posix.Process.W_STOPPED s => |
53 | Posix.Process.W_STOPPED s => |
54 Result (512 + LargeWord.toInt (Posix.Signal.toWord s))); |
54 Result (512 + LargeWord.toInt (Posix.Signal.toWord s))); |
55 in Synchronized.change result (K res) end |
55 in Synchronized.change result (K res) end |
56 handle exn => |
56 handle exn => |
57 (Synchronized.change result (fn Wait => Signal | res => res); reraise exn))); |
57 (Synchronized.change result (fn Wait => Signal | res => res); Exn.reraise exn))); |
58 |
58 |
59 fun read_pid 0 = NONE |
59 fun read_pid 0 = NONE |
60 | read_pid count = |
60 | read_pid count = |
61 (case (Int.fromString (File.read pid_path) handle IO.Io _ => NONE) of |
61 (case (Int.fromString (File.read pid_path) handle IO.Io _ => NONE) of |
62 NONE => (OS.Process.sleep (seconds 0.1); read_pid (count - 1)) |
62 NONE => (OS.Process.sleep (seconds 0.1); read_pid (count - 1)) |
93 val err = the_default "" (try File.read err_path); |
93 val err = the_default "" (try File.read err_path); |
94 val rc = (case Synchronized.value result of Signal => Exn.interrupt () | Result rc => rc); |
94 val rc = (case Synchronized.value result of Signal => Exn.interrupt () | Result rc => rc); |
95 val pid = read_pid 1; |
95 val pid = read_pid 1; |
96 val _ = cleanup (); |
96 val _ = cleanup (); |
97 in {out = out, err = err, rc = rc, terminate = fn () => terminate pid} end |
97 in {out = out, err = err, rc = rc, terminate = fn () => terminate pid} end |
98 handle exn => (terminate (read_pid 10); cleanup (); reraise exn) |
98 handle exn => (terminate (read_pid 10); cleanup (); Exn.reraise exn) |
99 end); |
99 end); |
100 |
100 |
101 end; |
101 end; |
102 |
102 |