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 (w1
, out
) = MLton
.TextIO.mkstemp
"/tmp/world"
23 val _
= TextIO.closeOut out
24 val (w2
, out
) = MLton
.TextIO.mkstemp
"/tmp/world"
25 val _
= TextIO.closeOut out
27 val _
= print
"before saves\n"
29 val original
= ref
true
31 val _
= (case save w1
of
32 Clone
=> original
:= false
35 val _
= print
"between saves\n"
37 val _
= (case save w2
of
38 Clone
=> original
:= false
41 val _
= print
"after saves\n"
44 then (run (fn () => load w1
)
45 ; run (fn () => load w2
)
46 ; OS
.FileSys
.remove w1
47 ; OS
.FileSys
.remove w2
)