🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #3296

Re: Exit handlers on the amiga

#3296
From: Michael Sinz - CATS
Date: Thu, 12 Apr 1990 13:35
41 lines
2679 bytes
In article <1720@cernvax.UUCP> rmal@cernvax.UUCP (richard lucock) writes:
>Does anyone know if there is a procedure that can be called to set up
>an exit-handler ? - ie to declare a user routine that will be called
>before the program is removed from the system (even in event of an
>exception such as address error, etc).

Just write a routine that calls the normal entry point.  Exiting a program
is done by doing an RTS.

>
>Or, failing this, does anyone know *how* a program is cleaned up ?
>(ie what part do compiler suplied routines play, what part do system
>routines play, etc). Thanks,

This depends on if the program ran from WorkBench or the CLI.  However,
the compiler stuff is always the same.

The SYSTEM (the OS) will cleanup the task structure (process structure)
and any CLI stuff.  It will also unload the code segments (via UnLoadSeg())
if your code was not resident.  It will also free the memory for the task
(or process) structure, the stack, and anything else that is in the
task structure's tc_MemEntry memory list.  (They can be allocated via
AllocEntry and AddHead() (or AddTail()) to the tc_MemEntry list.)

The compiler (or the standard library code) must free anything that it
allocates and does not link in with the system.  This usually goes for
any memory from malloc() (and its varients), file handles from open()
and fopen()  (all level 1 and level 2 I/O, not the AmigaDos Open())
and any other thing that is done with standard library calls.
AmigaExec calls to things such as AllocMem() are the responsibility of
the programmer.  They may be items that are linked to the tc_MemEntry
of the task or they are things that the programmer calls the correct
deallocation routines for.

/----------------------------------------------------------------------\
|      /// Michael Sinz -- CATS/Amiga Software Engineer                |
|     ///  PHONE 215-431-9422  UUCP ( uunet | rutgers ) !cbmvax!mks    |
|    ///                                                               |
|\\\///          "I don't think so," said Ren'e Descartes.             |
| \XX/                    Just then, he vanished.                      |
\----------------------------------------------------------------------/
Technical Details
Message-ID: <10821@cbmvax.commodore.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!cbmvax!mks
References: <1720@cernvax.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!cbmvax!mks
From: mks@cbmvax.commodore.com (Michael Sinz - CATS)
Newsgroups: comp.sys.amiga.tech
Subject: Re: Exit handlers on the amiga
Message-ID: <10821@cbmvax.commodore.com>
Date: 12 Apr 90 13:35:55 GMT
References: <1720@cernvax.UUCP>
Reply-To: mks@cbmvax (Michael Sinz - CATS)
Organization: Commodore, West Chester, PA
Lines: 41