FORK
PLBCMP Linux Only
The FORK instruction provides a method of executing two PL/B instruction streams simultaneously as two programs initiated by the same user. FORK provides the ability to perform non-interactive PL/B functions concurrently with interactive PL/B instructions. This is especially useful for off-line data processing, such as batch processing or report generation. The initiating program is considered the parent, the background task being the child process. The instruction uses the following format:
|
|
|
|
|
Where:
label
Optional. A Program Execution Label.
in
Required. A previously defined Character String Variable or a string Literal indicating the standard input (stdin) redirection for the child process.
out
Required. A previously defined Character String Variable or a string Literal indicating the standard output (stdout) redirection for the child process.
Flags Affected: OVER, ZERO
Note the following:
If insufficient system resources exist to initiate the child process, The ZERO flag is set.
The OVER flag is set in the child process and FALSE in the parent. The OVER flag may then select different code paths for the parent and child to execute.
If {out} is omitted, standard output (stdout) is unchanged and the child process' stdout appears in the parent's. If "/dev/null" for Linux or "nul" for MSDOS is desired, it must be provided explicitly.
If {in} is omitted, standard input (stdin) is closed and the child process must be capable of executing without input. Any KEYINs executed in the child process are treated as null entries.
When a child process begins, its copies of the parent's files are not open. The child process must open any files needed before attempting to use them.
The child process must terminate with a SHUTDOWN.
The child process initiated is a duplicate of the current program, and execution begins at the current position within the new program.
Pointer Data Definitions are invalid in the child process and must be reinitialized if desired.
It is not recommended to Trace across a FORK instruction with the Debugger.
See Also: Example Code, BATCH, EXECUTE, ROLLOUT, SHUTDOWN, System Interface Instructions
![]() |