[net.micro.amiga] Trapping Control-C in C Programs

sroth@muddcs.UUCP (Steve Roth) (10/26/85)

Does anyone know how to trap control-c from a program written in Lattice
C on the Amiga?  After hours poring over manuals I have no clue.

						Thanks,
						Steve

Reply to:  ...!ucbvax!ingres!sugiyama

louie@trantor.UMD.EDU (10/28/85)

From: Louis A. Mamakos <louie@trantor.UMD.EDU>

I think this is mentioned in a READ.ME file somewhere on the Lattice C V1.0
disk.  I remember seeing something about it there;  I don't have it handy
right now.

Louis A. Mamakos WA3YMH   University of Maryland, Computer Science Center
 Internet: louie@trantor.arpa  -or-  louie@TRANTOR.UMD.EDU

bruceb@amiga.UUCP (Bruce Barrett) (10/30/85)

In response to the question about detecting program interruption
from Lattice C I am including the following text from the next
READ.ME file.

""- TASK INTERRUPTION -

Detection of Ctrl-C and Ctrl-D is provided in the I/O library. If the external
integer location Enable_Abort is set to non-zero a check for these conditions
is performed every time a level-1 I/O call is made. If either of these keys
were pressed, the appropriate character is echoed to stdout, all level-1
files are closed, and the program terminates. Programs that do not use
level-1 I/O or that wish to check more frequently may call the function
Chk_Abort(), which will return zero if neither of the keys were pressed, or
the signal value if either key was pressed. Note that if Enable_Abort is non-
zero a successful call to Chk_Abort (either key had been pressed) will result
in program termination as described above.""

CAUTION:  The closing of files and freeing of memory that is done "for you"
by C is limited to the files and memory allocation that the C runtime
system knows about (documented in the C manual).  If you use any ROM or
AmigaDOS routines (documented else where) C will NOT clean those up.

(Good /Amiga/ programmers clean up after themselves)