The procedures described in this section control the creation of processes
and the execution of programs.
They are in the structures posix-process
and posix
.
Fork
creates a new child process and returns the child's process-id in
the parent and #f
in the child.
Fork-and-forget
calls thunk
in a new process; no process-id
is returned.
Fork-and-forget
uses an intermediate process to avoid creating
a zombie process.
(process-id? x) -> boolean
(process-id=? process-id0 process-id1) -> boolean
(process-id->integer process-id) -> integer
(integer->process-id integer) -> process-id
Process-id?
is a predicate for process-ids,
process-id=?
compares two to see if they are the same,
and process-id-uid
returns the actual Unix id.
Process-id->integer
and integer->process-id
convert process ids to and from integers.
(process-id-exit-status process-id) -> integer or #f
(process-id-terminating-signal process-id) -> signal or #f
(wait-for-child-process process-id)
process-id-exit-status
will return its exit status.
If the process is still running or was terminated by a signal then
process-id-exit-status
will return #f
.
Similarly, if a child process was terminated by a signal
process-id-terminating-signal
will return that signal and
will return #f
if the process is still running or terminated
normally.
Wait-for-child-process
blocks until the child process terminates.
Scheme 48 may reap child processes before the user requests their
exit status, but it does not always do so.
Terminates the current process with the integer status
as its exit status.
(exec program-name arg0 ...)
(exec-with-environment program-name env arg0 ...)
(exec-file filename arg0 ...)
(exec-file-with-environment filename env arg0 ...)
(exec-with-alias name lookup? maybe-env arguments)
Exec
and exec-with-environment
look up the new program in the search path,
while exec-file
and exec-file-with-environment
execute a particular file.
The environment is either inherited from the current process
(exec
and exec-file
) or given as an argument
(...-with-environment
).
Program-name
and filename
and any argi
should be strings.
Env
should be a list of strings of the form
"name
=value
"
.
The first four procedures add their first argument, program-name
or
filename
, before the arg0 ...
arguments.
Exec-with-alias
is an omnibus procedure that subsumes the other
four.
Name
is looked up in the search path if lookup?
is true
and is used as a filename otherwise.
Maybe-env
is either a list of strings for the environment of the
new program or #f
in which case the new program inherits its
environment from the current one.
Arguments
should be a list of strings; unlike with the other four
procedures, name
is not added to this list (hence -with-alias
).
Previous: Process primitives | Next: Process primitives