Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to index page
Thread view  Board view
Laaca

Homepage

Czech republic,
15.10.2022, 00:52
 

CTRL-break handling in the Freepascal programs (Developers)

As you maybe know, FPC uses the DJGPP compatible memory and interrupt architecture (but not the LibC library).

One of the consequencies is that the FPC programs can be anytime interrupted by CTRL-C, CTRL-Break and CTRL-\

It is not always the desidered behaviour.
Unfortunately, the FreePascal documentation says nothing about it.

However for a quite long time I know that the CTRL-C and CTRL-\ signaling can be turned off by calling <Set_CTRL_C(false)> from unit DPMIExcp.

But this does not help for CTRL-Break.

I had to investigate the DJGPP sources and there I found that there is a variable __djgpp_hwint_flags.

It has even an alias in the DPMIExcp to <djgpp_hwint_flags>

So, the magic code for turning off the CTRL-C, CTRL-Break and CTRL-\ is:

var djgpp_hwint_flags : word;external name '___djgpp_hwint_flags';
begin
djgpp_hwint_flags:=3;
writeln('Do not shy to press CTRL-C or CTRL-Break and then Enter);
readln;
writeln('We survived the CTRL-C and CTRL-Break');
end.


Note, that in the code I set the <djgpp_hwint_flags> to WORD and not to LONGINT like is done in the DPMIEXCP.
I am pretty sure that that is a bug in DPMIEXCP code (it should really be WORD)

---
DOS-u-akbar!

glennmcc

Homepage E-mail

North Jackson, Ohio (USA),
15.10.2022, 02:09

@ Laaca
 

CTRL-break handling in the Freepascal programs

> As you maybe know, FPC uses the DJGPP compatible memory and interrupt
> architecture (but not the LibC library).
>
> One of the consequencies is that the FPC programs can be anytime
> interrupted by CTRL-C, CTRL-Break and CTRL-\
>
> It is not always the desidered behaviour.
> Unfortunately, the FreePascal documentation says nothing about it.
>
> However for a quite long time I know that the CTRL-C and CTRL-\ signaling
> can be turned off by calling <Set_CTRL_C(false)> from unit DPMIExcp.
>
> But this does not help for CTRL-Break.
>
> I had to investigate the DJGPP sources and there I found that there is a
> variable __djgpp_hwint_flags.
>
> It has even an alias in the DPMIExcp to <djgpp_hwint_flags>
>
> So, the magic code for turning off the CTRL-C, CTRL-Break and CTRL-\ is:
>
> var djgpp_hwint_flags : word;external name '___djgpp_hwint_flags';
> begin
> djgpp_hwint_flags:=3;
> writeln('Do not shy to press CTRL-C or CTRL-Break and then Enter);
> readln;
> writeln('We survived the CTRL-C and CTRL-Break');
> end.
>

>
> Note, that in the code I set the <djgpp_hwint_flags> to WORD and not to
> LONGINT like is done in the DPMIEXCP.
> I am pretty sure that that is a bug in DPMIEXCP code (it should really be
> WORD)

Q: With all of that turned-off,
is there some other key press which _can_ be used to interupt the program
if one should desire to do so ?

---
--
http://glennmcc.org/

Laaca

Homepage

Czech republic,
15.10.2022, 08:31

@ glennmcc
 

CTRL-break handling in the Freepascal programs

> Q: With all of that turned-off,
> is there some other key press which _can_ be used to interupt the
> program
> if one should desire to do so ?


It is possible to turn off the CTRL-Break only, keep CTRL-C signal and even redirect it to another key combination.



/* Hardware Interrupt Flags:

1 = Disable INTR and QUIT keys (Ctrl-C and Ctrl-\);
2 = Count Ctrl-Break (don't kill);
4 = IRET from our timer interrupt handler, don't chain */

---
DOS-u-akbar!

Back to index page
Thread view  Board view
22049 Postings in 2034 Threads, 396 registered users, 83 users online (0 registered, 83 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum