UNIX process
This subsection describes a conceptual model of the UNIX process.
The C language process model is used by the UNIXProcess class. Each process is defined as having an input stream (stdin), an output stream (stdout), and an error stream (stderr). The streams made available by a UNIXProcess are defined when they are created.
There are three stages in the life of a UNIXProcess:
Creation of an instance. This includes definition of the environment to be used, the arguments to be passed to the process, and a Boolean flag for the input/output/error streams.
Reading or writing data on the input/output/error streams (blocking or non-blocking).
Termination, either forced or automatic (blocking or non-blocking).
Through the UNIXProcess class, operating system processes can be controlled from within Smalltalk.
Three file descriptors, stdin, stdout, and stderr, are available through the C language. Direct access to these file descriptors is possible for each instance of the UNIXProcess class. While directly accessing the file descriptors is possible, a stream-based abstraction is the preferred method of interaction.
An instance of the UNIXWritePipeStream class is used to access stdin while instances of UNIXReadPipeStream are used to access stdout and stderr. The UNIXWritePipeStream class and UNIXReadPipeStream class (described in the section entitled UNIX pipe stream) support a subset of the stream protocol. An instance of UNIXProcess responds to the messages stdin, stdout, and stderr by answering a UNIXPipeStream associated with the operating system's stdin, stdout or stderr pipe, respectively. If there is no corresponding UNIX pipe (if it was not requested when the UNIXProcess was created), then nil is answered.
Note:
Many UNIX processes that have stdin defined will not terminate unless stdin has been closed. Sending the message close to the UNIXWritePipeStream representing stdin closes the pipe and allows the process to end if it is blocked on input.
Last modified date: 01/29/2015