Mail Archives: djgpp/2000/02/09/16:11:52
Eli Zaretskii <eliz AT is DOT elta DOT co DOT il> wrote in article
<Pine DOT SUN DOT 3 DOT 91 DOT 1000209090433 DOT 9816J-100000 AT is>...
On Tue, 8 Feb 2000, Antti Koskipää wrote:
>> I'm working on a little program (18000+ lines of code already =)
>> and I want to disable Ctrl-C trapping. With _go32_want_ctrl_break()
>> I can disable Ctrl-Break. Great. But when I press Ctrl-C, the program
>> bombs with quadruple faults.
> I suggest to forget about `_go32_want_ctrl_break', it's there only for
> back-compatibility. Use the library function `signal' to install a
> handler for the SIGINT signal, and it will catch both Ctrl-C and
> Ctrl-BREAK. If your handler returns, the program will continue.
Ok, I did this:
void my_sigint (int foo)
{
foo = foo;
}
...
int main ()
{
old_sigint = signal (SIGINT, my_sigint);
...
It does not work. It just doesn't. Crashes with SIGINT like before.
'signal' works with SIGSEGV though.
I use it to detect which DPMI ring I'm running on and longjmp out of the
handler...
__djgpp_set_ctrl_c() works, but I don't want the side-effects.
Should I hook all of SIG: INT, ABRT, QUIT, ILL, etc...?
>> If I shell out from the proggy, press Ctrl-C on the command line
>> (DOS prints the ^C and a CR) and type exit to return, the program
>> crashes again. This is ridiculous!
> Why ridiculous? This is intended behavior: SIGINT is passed to all
> the parent processes. The motivation is compatibility with Unix,
> where signals are always passed to the parents. If the parent process
> wants to ignore SIGINT's while the child runs, it needs to reset
> SIGINT hadnling to SIG_IGN, or install a handler that simply returns.
I meant that it's ridiculous that a program crashes just like that, the
behaviour is fine.
>> Is there any way to disable Ctrl-C from causing an exception other than
>> writing my own keyboard handler?
>Yes, by reading the fine docs ;-).
That's funny, my libc list does not mention that function. DJGPP 2.01 I
guess.
- Antti
-- To reply via mail, remove you-know-what.
- Raw text -