1 fun statusToString status
=
3 Posix
.Process
.W_EXITED
=> "W_EXITED"
4 | Posix
.Process
.W_EXITSTATUS w
=> concat
["W_EXITSTATUS ", Word8.toString w
]
5 | Posix
.Process
.W_SIGNALED s
=>
6 concat
["W_SIGNALED ", SysWord
.toString (Posix
.Signal
.toWord s
)]
7 | Posix
.Process
.W_STOPPED s
=>
8 concat
["W_STOPPED ", SysWord
.toString (Posix
.Signal
.toWord s
)]
10 val cmd
= CommandLine
.name ()
13 TextIO.output (TextIO.stdOut
, "Hello world! [stdout]\n")
14 fun exit () = Posix
.Process
.exit
0wx7
15 fun diverge () = diverge ()
21 val _
= TextIO.flushOut (TextIO.stdOut
)
22 val _
= TextIO.flushOut (TextIO.stdErr
)
28 stdin
= MLton
.Process
.Param
.self
,
29 stdout
= MLton
.Process
.Param
.self
,
30 stderr
= MLton
.Process
.Param
.self
}
33 MLton
.Process
.reap pid
34 fun kill (pid
, signal
) =
35 MLton
.Process
.kill (pid
, signal
)
36 fun doTest (arg
, withPid
) =
38 val _
= print (concat
["testing ", arg
, "...\n"])
42 val _
= print (concat
["exit_status: ", statusToString status
, "\n"])
46 fun doSimpleTest arg
= doTest (arg
, fn _
=> ())
48 print
"create test:\n"
49 ; doSimpleTest
"stdout"
51 ; doTest ("diverge", fn pid
=> kill (pid
, Posix
.Signal
.kill
))
55 case CommandLine
.arguments () of
57 |
["stdout"] => stdout ()
59 |
["diverge"] => diverge ()