Signal Exceptions
An OS/2 Version 2.X application may receive three signals:
XCPT_SIGNAL_INTR (Ctrl+C)
XCPT_SIGNAL_KILLPROC (DosKillProcess)
XCPT_SIGNAL_BREAK (Ctrl+Break).
The signal being sent may be determined by examining the exception information in the ExceptionReportRecord.
Exception Code:
ExceptionInfo[ 0 ]
Number
XCPT_SIGNAL is called a "signal exception" and is sent only to thread 1 in the process receiving the exception. This is consistent with 16-bit signals, and provides greater consistency in the environment of the process for handling the various asynchronous exceptions. For example, since a repeated typematic Ctrl+C could possibly cause the thread to recursively process the exception and consume stack space without ever being able to handle the first "signal", the exception dispatcher "holds" each exception of the same type until a handler either returns XCPT_CONTINUE_EXECUTION to the exception dispatcher, or the process calls DosAcknowledgeSignalException for that signal. Only one signal or exception is actually held (they are not queued by the system).
DosAcknowledgeSignalException indicates to the system that the process wants to receive the XCPT_SIGNAL_INTR and XCPT_SIGNAL_BREAK signals. Previously, when a process called DosAcknowledgeSignalException the system noted that the process was aware of the particular signal for which it was registering the handler. When a process called DosAcknowledgeSignalException, it became a candidate for the "signal focus" for its session. At any point in time, the focus for a session is the last process to register a signal handler for that signal. When the user presses Ctrl+C on the keyboard, the system delivers an XCPT_SIGNAL_INTR signal to the current keyboard focus. The user could also press Ctrl+Break to deliver an XCPT_SIGNAL_BREAK signal, but this would only work if input were in raw mode.
Note that all exception handlers (on thread 1) must be prepared to "see" signal exceptions. It is always possible that a previous handler has issued DosSetSignalExceptionFocus, or that a Dos16SetSigHandler has been issued by some 16-bit code in the path. They can always be ignored by returning XCPT_CONTINUE_SEARCH to the exception dispatcher. Note that signals result in a call to the 16-bit signal handler (if installed) if all the 32-bit exception handlers return XCPT_CONTINUE_SEARCH.
DosSetSession performs the function of assigning the signal focus exactly as if the application had called DosAcknowledgeSignalException twice, once for each signal. The process calls DosSetSession when it wants to indicate that it expects to receive XCPT_SIGNAL_INTR or XCPT_SIGNAL_BREAK after it has registered an exception handler to process the signal when it comes. Each call to DosSetSession increments a counter in the PTDA of the process. When the system attempts to send XCPT_SIGNAL_INTR or XCPT_SIGNAL_BREAK to a process, it first checks to see if either this counter is greater than zero, or if the process has registered a 16-bit signal handler for that signal. If either of these is true, the signal will be sent. If the process has registered both 16-bit and 32-bit handlers, the 32-bit handlers are called first. If they do not handle the signal, the 16-bit handlers are called. If the 32-bit handlers are called and do not handle the signal, and there are no 16-bit handlers, the process is terminated.