1 (* Copyright (C
) 2004-2006 Henry Cejtin
, Matthew Fluet
, Suresh
2 * Jagannathan
, and Stephen Weeks
.
4 * MLton is released under a BSD
-style license
.
5 * See the file MLton
-LICENSE for details
.
8 (* Rewritten by wesley@terpstra
.ca on
2004-11-23 to use MLtonProcess for the
12 structure Unix
: UNIX
=
15 structure Status
= OS_Process
.Status
16 structure Process
= MLtonProcess
20 structure Child
= Child
21 structure Param
= Param
24 type signal
= Posix
.Signal
.signal
25 datatype exit_status
= datatype Posix
.Process
.exit_status
27 val fromStatus
= Posix
.Process
.fromStatus
29 type ('in, 'out
) proc
= ('out
, 'in, Process
.none
) Process
.t
32 fun create
{args
, env
, path
} =
33 Process
.create
{args
= args
,
40 fun execute (path
, args
) =
41 create
{args
= args
, env
= NONE
, path
= path
}
42 fun executeInEnv (path
, args
, env
) =
43 create
{args
= args
, env
= SOME env
, path
= path
}
46 fun binInstreamOf proc
= Child
.binIn (Process
.getStdout proc
)
47 fun binOutstreamOf proc
= Child
.binOut (Process
.getStdin proc
)
48 fun textInstreamOf proc
= Child
.textIn (Process
.getStdout proc
)
49 fun textOutstreamOf proc
= Child
.textOut (Process
.getStdin proc
)
51 fun streamsOf pr
= (textInstreamOf pr
, textOutstreamOf pr
)
53 val kill
= Process
.kill
55 fun reap z
= Status
.fromPosix (Process
.reap z
)
57 fun exit (w
: Word8.word): 'a
=
58 OS
.Process
.exit (Status
.fromInt (Word8.toInt w
))