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

From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Untrapping Ctrl-C in DJGPP
Date: Wed, 9 Feb 2000 09:05:26 +0200
Organization: NetVision Israel
Lines: 27
Message-ID: <Pine.SUN.3.91.1000209090433.9816J-100000@is>
References: <01bf725f$15b1d9e0$12e126d4 AT pena-ii>
NNTP-Posting-Host: is.elta.co.il
Mime-Version: 1.0
X-Trace: news.netvision.net.il 950080109 13219 199.203.121.2 (9 Feb 2000 07:08:29 GMT)
X-Complaints-To: abuse AT netvision DOT net DOT il
NNTP-Posting-Date: 9 Feb 2000 07:08:29 GMT
X-Sender: eliz AT is
In-Reply-To: <01bf725f$15b1d9e0$12e126d4@pena-ii>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
X-MIME-Autoconverted: from QUOTED-PRINTABLE to 8bit by delorie.com id DAB00870
Reply-To: djgpp AT delorie DOT com
Errors-To: dj-admin AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

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.

> 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.

> 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 ;-).

- Raw text -


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