[comp.sys.amiga.tech] Trapping for control-C.

joe@dayton.UUCP (Joseph P. Larson) (05/01/89)

Okay.  I'm tired of rebooting my Amiga every 15 or 20 minutes.  I'm working
on a program that really *needs* to call a routine called "cleanup" on
exit.  But the program doesn't work real good yet, and I end up ctrl-C-ing
out of all my debug statements once I see what's going on.

So here I am all set to add a call to the UNIX signal() function, but I
see that the Amiga version looks a lot more like the kill() function.

And Rob Peck's book doesn't explan this.  Nor do I have the "exec" RKM.
So, can I tell the Amiga to call cleanup() on ctrl-C, then ignore the
possibility afterwards?  (cleanup calls exit...)  Under unix, I would
just do:  signal(SIGINT, cleanup); signal(SIGQUIT, cleanup); (or whatever
the arg order is).  I suspect this would fall under "exception processing"
which Rob tells us he isn't going to tell us anything.

If this is possible, does anyone have a code fragment I could use?

-Joe
-- 
Life is a cabaret (old chum).
UUCP: rutgers!dayton!joe   (Picts 1-13 are   DHDSC - Joe Larson/MIS 1060
ATT : (612) 375-3537       now ready.)       700 on the Mall, Mpls, Mn. 55402

paolucci@snll-arpagw.UUCP (Sam Paolucci) (05/01/89)

In article <6528@dayton.UUCP> joe@dayton.UUCP (Joseph P. Larson) writes:
->
->Okay.  I'm tired of rebooting my Amiga every 15 or 20 minutes.  I'm working
->on a program that really *needs* to call a routine called "cleanup" on
->exit.  But the program doesn't work real good yet, and I end up ctrl-C-ing
->out of all my debug statements once I see what's going on.
->
->So here I am all set to add a call to the UNIX signal() function, but I
->see that the Amiga version looks a lot more like the kill() function.
->
->And Rob Peck's book doesn't explan this.  Nor do I have the "exec" RKM.
->So, can I tell the Amiga to call cleanup() on ctrl-C, then ignore the
->possibility afterwards?  (cleanup calls exit...)  Under unix, I would
->just do:  signal(SIGINT, cleanup); signal(SIGQUIT, cleanup); (or whatever
->the arg order is).  I suspect this would fall under "exception processing"
->which Rob tells us he isn't going to tell us anything.
->
->If this is possible, does anyone have a code fragment I could use?

As far as I know (and I might have used it in the past, but don't recall
now) signal() and SIGINT are supported by both Manx and Lattice, and should
work exactly for what you want to do.


-- 
					-+= SAM =+-
"the best things in life are free"

				ARPA: paolucci@snll-arpagw.llnl.gov

cmcmanis%pepper@Sun.COM (Chuck McManis) (05/01/89)

In article <6528@dayton.UUCP> (Joseph P. Larson) writes:
>just do:  signal(SIGINT, cleanup); signal(SIGQUIT, cleanup); (or whatever
>the arg order is). 

This works fine with the Lattice 5.0 compiler. 


--Chuck McManis
uucp: {anywhere}!sun!cmcmanis   BIX: cmcmanis  ARPAnet: cmcmanis@sun.com
These opinions are my own and no one elses, but you knew that didn't you.
"A most excellent barbarian ... Genghis Kahn!"