BACKGROUND Verb - Operate Current Program in Background


BACKGROUND str{,ERR=lineref}


The BACKGROUND verb, if available on the local operating system, (see the specific operating system manual for more information) allows the current program to continue operating in the background and starts a new foreground task attached to the current terminal (Note that the BACKGROUND Verb is not supported in a Windows environment).

The background process stops if an untrapped error occurs; therefore, trap and log all errors in the application code.




Program to start as the new foreground process. The new foreground process communicates with the user and inherits the original FID(0), but no other files or devices are left open.


Branch to be taken if an error occurs during execution.

The "background" process retains all original files, devices, programs, and data, except that the device "IO" is now associated with channel 0. A READ or INPUT from channel 0 in the background program always returns an !ERROR=2. WRITE and PRINT are permitted to finish; however, the output data is lost. A FIN(0) call returns the data associated with device "IO". STBL data and the options vector are retained on both processes.

Notes for developers using the BACKGROUND verb:

The program executing the BACKGROUND verb can be thought of as being replaced with a different program in the foreground, while continuing to execute in the background. Therefore, all OPENed files and pipes are passed to the background process and are no longer available to the program in the foreground. Locked records (using EXTRACT) may not remain locked during the transition to the background.

The background process is, in a sense, the "same" program that was running in the foreground. It is, however, a different process and can have a different process ID to the operating system. Any system relying on the process ID (such as in a "lock file") may not function properly after the BACKGROUND verb is used.

In general, programs that use the BACKGROUND verb should not rely on either the parent's or the child's process ID remaining the same.

C-ISAM files are controlled only by a library linked to PRO/5. The behavior of a C-ISAM file opened before a BACKGROUND verb is not predictable. Only open C-ISAM files after the execution of a BACKGROUND verb.



See Also

Verbs - Alphabetical Listing