1 fun run (f
: unit
-> unit
) =
2 case Posix
.Process
.fork () of
6 val (pid
', status
) = waitpid (W_CHILD pid
, [])
7 in if pid
= pid
' andalso status
= W_EXITED
9 else raise Fail
"child failed"
11 | NONE
=> let open OS
.Process
12 in exit ((f (); success
) handle _
=> failure
)
22 val (w
, out
) = MLton
.TextIO.mkstemp
"/tmp/world"
23 val _
= TextIO.closeOut out
34 val _
= (f
13; ()) handle Foo
=> (print
"caught foo\n"; succeed ())
36 val _
= run (fn () => load w
)
38 val _
= OS
.FileSys
.remove w