INT 23H: Ctrl-Break Exit Address
The INT 23H vector (0000:008c) points to the code that will receive
control when DOS senses that the user has pressed Ctrl-Break.
The address at the INT 23H vector is copied into the pfCtlBrk field of the
PSP by DOS fn 26H (create PSP) and fn 4bH (EXEC). The original address of
the Ctrl-Break handler is restored from the PSP when a program exits.
Thus, the parent's Ctrl-Break handler will be restored upon exit from the
child process.
█▌Break Sensing▐█
DOS invokes INT 23H when it senses that the user has pressed Ctrl+C
(ASCII 03H) Ctrl-Break. The level of DOS Ctrl-Break sensing can be
checked or set via fn 33H as follows:
■ If Break sensing is OFF, DOS senses Ctrl-Break only during console,
printer, and serial device I/O.
■ If Break sensing is ON, DOS senses Ctrl-Break during all fns except 06H
and 07H.
█▌Custom Break Handling▐█
Normal DOS break-handling is handled by COMMAND.COM. It causes a program
to terminate immediately. If you use network file-locking or want avoid
the ugly DOS ^C display, you should intercept INT 23H and handle
Ctrl+Break in your own program. Please note:
■ Use Fn 25H to set the INT 23H vector to point to your own code.
■ Upon entry to your Ctrl-Break handler:
• All registers are set as they were upon entry to the DOS function
that sensed Ctrl-Break.
• SS:SP is set to a DOS internal stack. The top of stack will contain
the CS:IP/Flags for an IRET to get back to DOS; below that is the
CS:IP/Flags for an IRET to get back to your program (you might use
this to figure out what part of your code was active when the user
pressed Break).
• DOS clears internal variables InDOS and ErrorMode, so that your
program can use DOS fns in the Break handler.
■ If you want to ignore Ctrl-Break, just issue an IRET. DOS restarts the
DOS fn that was interrupted, and eventually returns to your program.
■ If you want to do something (e.g., halt a repeat action), then be sure
to save all registers before taking action and restore all registers
afterwards.
Exit via an IRET. There are no restrictions on what your break handler
may do -- all DOS functions are allowed. However, if the break handler
itself performs character I/O, and the user presses Ctrl-Break again,
DOS crashes and burns.
■ If you want to abort (exit to the parent process), then set the carry
flag and return via a FAR RET. This causes DOS to perform normal
cleanup and exit to the parent.
■ An easy way to ensure that a process notices an occurrence of
Ctrl-Break is to perform DOS Fn 0bH every once in a while.
See Also: Program Startup & Exit
fn 33H (query/set Break-checking)
INT 1bH (invoked by BIOS on Ctrl+Break)
DOS Functions
-♦-