Re: [cc65] signals

From: Oliver Schmidt <ol.sc1web.de>
Date: 2005-05-27 15:31:28
Hi,

> > I want to override _sig_dfl for BBC micro so that it traps
> > SIGINT and aborts to the OS when Escape is pressed and not
> > captured. What is the best way of doing this? I don't want to move
> > it from common otherwise it'll need redefining for all the other
> > architectures...
> 
> I had a discussion with Oliver regarding this topic, and we came to the
> conclusion that - at least for the Apple - it is almost impossible to map an
> asynchronous signal to a signal handler, and terminate the program in this
> case. If the Escape key generates something like an interrupt, you don't know,
> which part of the code has been interrupted. Hard aborting the program is
> possible, but even this may leave the operating system in an unstable state.
> Executing more cc65 code (like flushing disk buffers) is not possible, because
> disk routines may have been interrupted, and most of the code is not
> reentrant.

In fact I recall this issue a little bit different ;-)

When you press Ctrl-Reset on an Apple2 a specific asynch handler gets
called and I wanted to call the C-Library cleanup function "donelib"
from that handler. So I asked Uz about his opinion. We started
thinking about raising a signal from within that handler a let the
application programmer decide what to do. Beside other arguments I
don't remember anymore exactly the finaly showstopper for this approach
was that the Ctrl-Reset "simply" asserts the RESET line on the CPU so
that the previous program counter gets lost. This means that it would
never ever be possible to ignore the signal in question (and continue
the running program). At that point Uz and I aggreed that the signal
semantic simply doesn't fit the Ctrl-Reset scenario.

So I reverted back to calling the C-Library cleanup from within the 
handler - although both the terms "handler" and "within" are probably
not correct because there's nothing to return to from that point.
Fortunately that's no issue for the Apple2 as after C-Library cleanup
a cc65 program doesn't try to return to somewhere but re-runs the BASIC
interpreter from scratch on a new stack.

This means that on the Apple2 there *IS* async C-Library cleanup - with
all problems that may cause! One important part is closing open files,
although that may be a little less risky than on other platforms because it
doesn't mean to itterate over cc65 datastructures to find the open
files. Instead the OS has a close_all call without parameters.

Please note that even application programmer written atexit functions
are called as part of this. Hopefully Uz doesn't insist in removing all 
that now ;-))

Oliver

______________________________________________________________
Verschicken Sie romantische, coole und witzige Bilder per SMS!
Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Fri May 27 15:31:44 2005

This archive was generated by hypermail 2.1.8 : 2005-05-27 15:31:46 CEST