On UNIX machines, handling devices poses a special problem. The difficulty is that UNIX does not in any way limit access to a device, so that it is possible for two programs to intermix reports on the same printer. This is usually not a problem with printers because the output is usually directed to the UNIX spooler. However, for special-form printing, or writing to other types of devices, it is necessary to write directly to the device.
On UNIX systems, runcbl can control concurrent access to a device by automatically performing file locking for all files identified as devices. You must enable this feature if you want to use it. When it is enabled, runcbl will create a lock file whenever a device file is opened. If the lock file exists when the open is made, then the open will fail and a file-locked condition will be returned to the program. When an open device file is closed, its lock file will be removed.
You identify a device to runcbl by using the -D flag in its name. The lock file will be called LOCK.name where name is the base file name of the UNIX device (for example, lp or mt0). See File Name Interpretation for more information.
You enable automatic device locking by specifying a lock directory. Set the configuration variable LOCK_DIR to the desired directory.
For example, if you wanted to enable device locking and place the lock files in the directory /usr/locks, you could use the following configuration variable:
Also note that enabling device locking will not prevent the UNIX spooler from printing to the device. When you are using a printer as a special-form printer, the spooler should first be disabled (see the disable UNIX command) and then the program should be run that will print the special forms. It will prevent other special-form printing programs from using that printer. Programs that print through the spooler, meanwhile, will continue to run, because the UNIX spooler accepts queued reports when disabled. After the special forms are printed, the spooler can be enabled and the queued reports will start printing.