delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/02/09/16:11:52

From: "Antti Koskipää" <antti DOT koskipaa AT NO DOT SPAM DOT PLEASE DOT nic DOT fi>
Subject: Re: Untrapping Ctrl-C in DJGPP
Newsgroups: comp.os.msdos.djgpp
References: <01bf725f$15b1d9e0$12e126d4 AT pena-ii> <Pine DOT SUN DOT 3 DOT 91 DOT 1000209090433 DOT 9816J-100000 AT is>
Message-ID: <01bf7348$40dc9260$69e126d4@pena-ii>
X-Newsreader: Microsoft Internet News 4.70.1155
Lines: 58
Date: Wed, 09 Feb 2000 20:49:54 GMT
NNTP-Posting-Host: 212.38.225.105
X-Trace: uutiset.nic.fi 950129394 212.38.225.105 (Wed, 09 Feb 2000 22:49:54 EET)
NNTP-Posting-Date: Wed, 09 Feb 2000 22:49:54 EET
Organization: NIC Tietoverkot Oy - NIC Data Networks Ltd.
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019