www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/01/14/07:55:42

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
Date: Mon, 14 Jan 2002 14:53:23 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: ROLAND <roland_asmann AT yahoo DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: PMCOM & signals
In-Reply-To: <20020114124132.15365.qmail@web9103.mail.yahoo.com>
Message-ID: <Pine.SUN.3.91.1020114144423.16401C@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Mon, 14 Jan 2002, ROLAND wrote:

> >    __djgpp_set_ctrl_c(0);
> 
> I don't want to fully ignore CTRL-C, because then I
> cannot quit my program...
> I just want to catch the interrupt with something
> like: signal(SIGINT,int_handler), which handles my
> interrupt (closing the COMPort and then quiting the
> program).

If the problem with Ctrl-C is what I suspect it is, then you cannot have 
the cake and eat it, too: by the time Ctrl-C is converted into a SIGINT, 
it's too late--the selector loaded into DS was already made invalid, 
because that's how the DJGPP signal support works.  And if your program 
crashes because PMCOM cannot cope with an invalid DS, you cannot let 
Ctrl-C invalidate DS.  The line I posted prevents that from happening.

> If I'm correct SIGINT is CTRL-C, right?

No.  SIGINT is _generated_ from Ctrl-C, by a special hardware interrupt 
handler installed by the DJGPP startup code.

> The problem is that the piece of code above, does not
> work.
> For some reason, when I press CTRL-C, my program
> terminates immediately (or so I guess...) and Windows
> complains about all kinds of references (mentioned in
> an earlier thread).

I don't understand: are you saying that adding this line:

    __djgpp_set_ctrl_c(0);

to your program breaks it?  That is, with this line in your program, 
pressing Ctrl-C causes the program to terminate immediately?

> I just want my program to exit without any errors when
> I press CTRL-C and return to the bash.

This can be done using a simple call to kdhit(), no?  Why do you need to 
get involved with yet another interrupt and signal?  I think you have 
enough interrupts and signals in that program even without Ctrl-C ;-)

- Raw text -


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