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
Forkcreates a new child process. In the parent process, it returns the child's process id; in the child process, it returns#f.Fork-and-forgetcalls thunk in a new process; no process id is returned.Fork-and-forgetuses 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-idconvert between Scheme48's opaque process id type and POSIX process id integers.
#f#fIf the process identified by pid exited normally or is running,
process-id-exit-statusandprocess-id-terminating-signalwill both return#f. If, however, it terminated abnormally,process-id-exit-statusreturns its exit status, and if it exited due to a signal thenprocess-id-terminating-signalreturns the signal due to which it exited.Wait-for-child-processblocks 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-environmentlook up the program in the search path (thePATHenvironment variable), whileexec-file&exec-file-with-environmentexecute 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
execvariants. 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-aliasdoes not prepend name to that list (hence-with-alias).