COBOL Manual for TNS/E Programs (H06.03+)
Terminal Input and Output
HP COBOL Manual for TNS/E Programs—520347-003
29-9
Getting Break Ownership
Getting Break Ownership
When you press Break on a terminal, the process that owns Break receives a system
message on $RECEIVE. A process discovers that Break has been pressed by reading
$RECEIVE. An HP COBOL process, lacking the ability to perform NOWAIT input and
output directly, must open $RECEIVE with an OPEN statement with a TIME LIMITS
phrase and then try to read $RECEIVE from time to time. If a READ statement fails
because it timed out, Break was not pressed.
When a command interpreter starts a process, whether or not the process uses the
command interpreter’s terminal for any input or output, the command interpreter retains
ownership of Break unless another process explicitly obtains ownership of Break from
the operating environment. All a process needs to do to obtain that ownership is:
•
Open the terminal for I-O (to get a stable file number, because DISPLAY and
ACCEPT open and close the terminal each time they are executed)
•
Call the COBOL_SETMODE_ routine with:
°
The file-name
°
The function code 11
°
The CPU, PIN (processor number, process number) of the process to receive
ownership as the first parameter
°
Zero as the second parameter
If you start a process from the command interpreter, and that process takes ownership
of Break but does not return ownership before terminating, the command interpreter
does not regain title to Break. You might have to get a system operator to stop and
restart your command interpreter in order for it to regain Break ownership.
Transferring Break Ownership
For one process to pass ownership of Break to another process, the first process must
determine the CPU and PIN of the second process. Then the first process can transfer
Break ownership to the other process by calling the operating system routine
SETMODE with the appropriate values for parameters 1 and 2 (see Getting Break
Ownership).
The most common reason to transfer Break ownership to another process is to return it
to its previous owner after you have accessed it.
If the process will return Break ownership to its previous owner after a time, another
parameter must be included in the call to receive the 4-byte value of the restoration
parameters. This enables the process to call SETMODE with the 4 bytes as
parameters 1 and 2 when it surrenders the ownership of the Break, as Example 29-4
shows.










