muppet wrote:

>> I understand initialization of an XS module may be modified using BOOT.
>> However, there seems to be no counterpart of BOOT. How do I e.g. free
>> memory I allocated in BOOT?
[..]
>> Or is the current practice to write an XS function that e.g. frees the
>> memory allocate at BOOT and call it in an END handler in the module's
>> Perl code?

> If your BOOT code creates perl objects that need to be cleaned up, or
> hangs on to anything that depends on perl objects, then atexit() is too
> late.  atexit() handlers get called after main() returns, and by that
> time, the interpreter has already shut down.

I don't want to call atexit(), but call call_atexit() :-). It's called
by DynaLoader (that's how I stumbled across it) and not documented in
perlapi. It's in perl.c (at least in the sources of the Perl we use on
the production systems).

> An END block would be a cleaner, more general solution, IMO, because you
> don't have to worry about your C teardown eventually trying to call back
> into a dead interpreter.

Is there a common practice for cleaning up or do people just trust the
OS to free everything when the process exits? ;-)

-- 
Dipl.-Inform. Gregor Goldbach (PKI Team)
Phone: +49 40 808077-621 Fax: +49 40 808077-556 Mail:goldb...@dfn-cert.de

DFN-CERT Services GmbH, https://www.dfn-cert.de, Phone  +49 40 808077-555
Sitz / Register: Hamburg, AG Hamburg, HRB 88805, Ust-IdNr.:  DE 232129737
Sachsenstraße 5,  20097 Hamburg/Germany, CEO: Dr. Klaus-Peter Kossakowski

                       16. DFN-Workshop Sicherheit in vernetzten Systemen
                                          https://www.dfn-cert.de/ws2009/

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to