yggy has asked for the wisdom of the Perl Monks concerning the following question:

I have an application with an embedded perl interpreter. Everything works great, except when a perl function chooses to 'die', the death message doesn't make its way back to the C code.

After calling eval_pv, SvTRUE(ERRSV) is true (an error occurred), but SvPV(ERRSV,len) returns a lengthy message about various evals failing, which does not include the message passed to die in the perl code.

For any particular 'die' I could simply return some sort of error code to the C program which could then take appropriate action -- I would prefer a generic mechanism for trapping die and handling the message from C.

Any tips? (I'd like to trap 'warn' as well, but that's less important.)

I'm using perl 5.6.1 from ActiveState with the regular perlembed.

Many thanks,
Yggy

Replies are listed 'Best First'.
Re: perl embedded in C -- how to trap die?
by Anonymous Monk on Jan 24, 2004 at 09:07 UTC
    answer is in perlcall