The Standard ML Basis Library

The OS.Process structure

The OS.Process structure provides functions for manipulating processes in an operating system independent manner. For discussion of additional relations between this structure and other structures, see Section 11.1.


signature OS_PROCESS
structure Process : OS_PROCESS


eqtype status
val success : status
val failure : status
val system : string -> status
val atExit : (unit -> unit) -> unit
val exit : status -> 'a
val terminate : status -> 'a
val getEnv : string -> string option


eqtype status
The status type represents various termination conditions for processes. On Posix-based systems, status will be be int.

is the unique status value that signifies successful termination of a process.

is a status value that signifies an error during execution of a process. Note that, in contrast to the success value, there may be several distinct failure values.

system cmd
asks the operating system to execute the command cmd, and to return the termination status of the command. Raises SysErr if the command cannot be executed.

Note that, although this function is independent of the operating system, the interpretation of the string cmd depends very much on the underlying operating system and shell.

atExit f
registers an action f to be executed when the current SML program calls exit. Actions will be executed in the reverse order of registration.

Exceptions raised when f is invoked that escape it are trapped and ignored. Calls in f to atExit are ignored. Calls to exit do not return, but should cause the remainder of the functions registered with atExit to be executed. Calls to terminate (or similar functions such as Posix.Process.exit) will terminate the process immediately.

exit st
executes all actions registered with atExit, flushes and closes all I/O streams, then terminates the SML process with termination status st.

terminate st
terminates the SML process with termination status st, without executing the actions registered with atExit or flushing open I/O streams.

getEnv s
An environment is associated with each SML process, modeled as a list of pairs of strings, corresponding to name-value pairs. (The way the environment is established depends on the host operating system.) The getEnv function scans the environment for a pair whose first component equals s. If successful, it returns the second component; otherwise, it returns NONE.

See Also

OS, OS.FileSys, OS.Path, OS.IO, Posix.ProcEnv, Posix.Process

[ INDEX | TOP | Parent | Root ]

Last Modified September 1, 1997
Comments to John Reppy.
Copyright © 1997 Bell Labs, Lucent Technologies