|
|
To illustrate the concepts of inheritance and scope of the
interrupt
and
oninterrupt
descriptors, the following menu definition files
define them with frame descriptors and item descriptors
in a menu definition file:
menu="My First Menu" begrow=center begcol=30 interrupt=truename=Run UNIX System V action=unix-system
name="Find Modified Files" action=`find $HOME -mtime -7 -print > modfiles`nop
name="Find Executable Files" action=`find $HOME -perm -100 -print > execfiles`nop
name="Exit My Application" action=exit
Menu.interrupt: an example of interrupt signal handling
When defined among the frame descriptors, the value of
interrupt
is inherited by all processes initiated in
action
descriptors anywhere in the menu definition file,
unless it is redefined for a particular item or SLK.
Thus, if the user selects either the
Find Modified Files
or
Find Executable Files
item from this menu, the named process will
run till its normal completion.
However, the user can interrupt either process
because
interrupt=true
is defined among the frame descriptors for this menu.
(Note that output from Find Modified Files is saved in a
file named modfiles,
and that output from Find Executable Files is saved in a
file named execfiles.)
When a user presses the interrupt key,
the message
Operation interrupted!
appears at the bottom of the screen and the process is terminated.
This is the default behavior when no other
messages or actions have been defined via the
oninterrupt
descriptor, as is the case in this menu.
You can be more specific about what processes you want users
to be able to interrupt
and about what you want done when a process is interrupted.
For example, you can block the interrupt mechanism for any item on the menu
by setting the
interrupt
descriptor to FALSE for the item.
A process initiated
from that item cannot be interrupted, even
if the frame descriptor
interrupt
is set to true:
menu="My First Menu" begrow=center begcol=30 interrupt=truename="Run UNIX System V" action=unix-system
name="Find Modified Files" action=`find $HOME -mtime -7 -print > modfiles`nop interrupt=false
name="Find Executable Files" action=`find $HOME -perm -100 -print > execfiles`nop oninterrupt=`message Partial output is in execfiles`nop
name="Exit My Application" action=exit
Menu.oninterr: a further example of interrupt handling
If a user selects
Find Modified Files
from this menu definition file, the process it initiates cannot be interrupted.
If a user selects
Find Executable Files
from this menu, it can be interrupted, and when it is,
the processing defined for this item
by the
oninterrupt
descriptor will occur.