Alternate Entry Name: _COBRK
B: count = .cobrk(fcv, quit_count);
C: int _cobrk(void *fcv, int quit_count);
.COBRK establishes a co-routine that is invoked if and when the user presses the terminal BREAK key. Once .COBRK has been used to establish a break-handler, pressing BREAK has the effect of
call(fcv,state);
where "fcv" is the co-routine identifier passed to .COBRK.
The "state" argument that is passed to the break-handling co-routine is a pointer to a 26 word vector. The first 25 words give the machine state of the program at the time BREAK was pressed (24 words of registers plus one word for the IC and I).
The 26th word (state[25]) is called the "break mask word", and it indicates what should happen if the user presses BREAK again, while the break-handling co-routine is executing. If the break mask word is non-zero, such breaks will be "masked": the system will maintain a count of how many times the user press BREAK, but there will be no apparent interruption in the break-handling co-routine's execution. Breaks are not masked if the break mask word is zero. When your break-handling co-routine is called, the break mask word will be non-zero.
When your break-handling co-routine finishes execution, it can do one of several things.
If the co-routine that was interrupted by BREAK is ever to be invoked again, you must save its 25 state words in some safe storage area before unmasking the program. Before re-invoking the interrupted co-routine, you must restore its "state" vector with these 25 state words. If your break processing has modified any other features of the program state that the interrupted co-routine may depend upon (e.g. the current read and write units), you must restore these features as well.
The B library keeps a count of the number of times BREAK is pressed. If this count exceeds "quit_count", the default break handler is invoked. This handler will terminate your program by calling EXIT. The break count and the break limit are the same count and limit maintained by NOBRKS, so NOBRKS can be used to set and/or retrieve these values. The accumulated count is only reset by a call to .COBRK or NOBRKS specifying a new limit.
It is best to keep break-processing to a minimum. If the system is kept masked for 10 consecutive breaks, the library will abort the program.
Copyright © 1996, Thinkage Ltd.