Posix.Process
structure
signature POSIX_PROCESS
structure Process
: POSIX_PROCESS
The structure Posix.Process
describes the primitive POSIX operations dealing with processes, as described in Section 3 of the POSIX standard 1003.1,1996[CITE].
eqtype signal
eqtype pid
val wordToPid : SysWord.word -> pid
val pidToWord : pid -> SysWord.word
val fork : unit -> pid option
val exec : string * string list -> 'a
val exece : string * string list * string list -> 'a
val execp : string * string list -> 'a
datatype waitpid_arg
= W_ANY_CHILD
| W_CHILD of pid
| W_SAME_GROUP
| W_GROUP of pid
datatype exit_status
= W_EXITED
| W_EXITSTATUS of Word8.word
| W_SIGNALED of signal
| W_STOPPED of signal
val fromStatus : OS.Process.status -> exit_status
structure W : sig
include BIT_FLAGS
val untraced : flags
end
val wait : unit -> pid * exit_status
val waitpid : waitpid_arg * W.flags list
-> pid * exit_status
val waitpid_nh : waitpid_arg * W.flags list
-> (pid * exit_status) option
val exit : Word8.word -> 'a
datatype killpid_arg
= K_PROC of pid
| K_SAME_GROUP
| K_GROUP of pid
val kill : killpid_arg * signal -> unit
val alarm : Time.time -> Time.time
val pause : unit -> unit
val sleep : Time.time -> Time.time
eqtype signal
eqtype pid
val wordToPid : SysWord.word -> pid
val pidToWord : pid -> SysWord.word
pid
value generated using wordToPid
is legal on the given system or that it corresponds to a currently running process.
val fork : unit -> pid option
fork
, both the parent and child process execute independently, but share various system resources. Upon successful completion, fork
returns NONE
in the child process, and the pid
of the child in the parent process. It raises OS.SysErr
on failure.
exec (path, args)
exece (path, args, env)
execp (file, args)
Normally, the new image is given the same environment as the calling program. The env argument in exece
allows the program to specify a new environment.
The args argument is a list of string arguments to be passed to the new program. By convention, the first item in args is some form of the filename of the new program, usually the last arc in the path or filename.
datatype waitpid_arg
= W_ANY_CHILD
| W_CHILD of pid
pid
| W_SAME_GROUP
| W_GROUP of pid
pid
.
datatype exit_status
= W_EXITED
| W_EXITSTATUS of Word8.word
| W_SIGNALED of signal
| W_STOPPED of signal
W_EXITSTATUS
must never be zero.
If an implementation provides both the Posix
and Unix
structures, then the datatypes Posix.Process.exit_status
and Unix.exit_status
must be the same.
fromStatus sts
structure W
val untraced : flags
val wait : unit -> pid * exit_status
wait
suspends execution until status information on one of its child processes is available. If status information is available prior to the execution of wait
, return is immediate. wait
returns the process ID of the child and its exit status.
waitpid (procs, l)
wait
except that the status is reported only for child processes specified by procs. A set of flags l may be used to modify the behavior of waitpid
.
waitpid_nh (procs, l)
waitpid
, except that the call does not suspend if status information for one of the children specified by procs is not immediately available.
Rationale:
In C,
waitpid_nh
is handled bywaitpid
, using an additional flag to indicate no hanging. In SML, the semantics ofwaitpid_nh
indicated a different return type from that ofwaitpid
, hence the split into two functions.
exit i
wait
related call, the exit status i is made available to it. exit
does not return to the caller.
Calling exit
does not flush or close any open IO
streams, nor does it call OS.Process.atExit
. It does close any open POSIX files, and performs the actions associated with the C version of exit
.
datatype killpid_arg
= K_PROC of pid
pid
.
| K_SAME_GROUP
| K_GROUP of pid
pid
.
kill (procs, sig)
alarm t
alrm
) to the calling process after t seconds have elapsed. If there is a previous alarm request with time remaining, the alarm
function returns a nonzero value corresponding to the number of seconds remaining on the previous request. Zero time is returned if there are no outstanding calls.
val pause : unit -> unit
sleep t
BIT_FLAGS
,OS.Process
,Posix
,Posix.Signal
Generated October 02, 2003
Last Modified July 1, 2002
Comments to John Reppy.
This document may be distributed freely over the internet as long as the copyright notice and license terms below are prominently displayed within every machine-readable copy.
Copyright © 2003 AT&T and Lucent Technologies. All rights reserved.
Permission is granted for internet users to make one paper copy for their
own personal use. Further hardcopy reproduction is strictly prohibited.
Permission to distribute the HTML document electronically on any medium
other than the internet must be requested from the copyright holders by
contacting the editors.
Printed versions of the SML Basis Manual are available from Cambridge
University Press.
To order, please visit
www.cup.org (North America) or
www.cup.cam.ac.uk (outside North America). |