Next: POSIX signals, Up: POSIX interface
The procedures described in this section control the creation of
subprocesses and the execution of programs. They exported by both the
posix-processes
and posix
structures.
#f
Fork
creates a new child process. In the parent process, it returns the child's process id; in the child process, it returns#f
.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-id?
is the disjoint type predicate for process ids.Process-id=?
tests whether two process ids are the same.Process-id->integer
&integer->process-id
convert between Scheme48's opaque process id type and POSIX process id integers.
#f
#f
If the process identified by pid exited normally or is running,
process-id-exit-status
andprocess-id-terminating-signal
will both return#f
. If, however, it terminated abnormally,process-id-exit-status
returns its exit status, and if it exited due to a signal thenprocess-id-terminating-signal
returns the signal due to which it exited.Wait-for-child-process
blocks the current process until the process identified by pid has terminated. Scheme48 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.
These all replace the current program with a new one. They differ in how the program is found and what process environment the program should receive.
Exec
&exec-with-environment
look up the program in the search path (thePATH
environment variable), whileexec-file
&exec-file-with-environment
execute a particular file. The environment is either inherited from the current process, in the cases ofexec
&exec-file
, or explicitly specified, in the cases ofexec-with-environment
&exec-file-with-environment
. Program, filename, & all arguments should be strings. Env should be a list of strings of the form"
name=
value"
. When the new program is invoked, its arguments consist of the program name prepended to the remaining specified arguments.
General omnibus procedure that subsumes the other
exec
variants. Name is looked up in the search path if lookup? is true or used as an ordinary filename if it is false. Maybe-env is either#f
, in which case the new program's environment should be inherited from the current process, or a list of strings of the above form for environments, which specifies the new program's environment. Arguments is a list of all of the program's arguments;exec-with-alias
does not prepend name to that list (hence-with-alias
).