[Date Prev][Date Next][Thread Prev][Thread Next]
[Search]
[Date Index]
[Thread Index]
Re: [MacPerl-AnyPerl] Trapping exit and die
At 17.02 +0000 1999.08.04, Bart Lateur wrote:
>On Wed, 4 Aug 1999 10:39:41 -0500, jason.whitehead@natinst.com wrote:
>
>>I was wondering if there is any way to trap the exit and die calls. I
>>need to be
>>able to take a script that is to be executed by Perl from C and make sure
>>that
>>any calls to exit or die are not called. Note, I need to be able to do
>>this from
>>C/C++ because I am running Perl scripts from an application written in C/C++.
>>Does anyone know a simple way of solving this problem.
>
>exit(): no luck. But die() is easy to trap using eval().
>
>You'd better replace all accurences of exit() with die(). Uh... can you
>overload exit()? I couldn't...
I could.
#!perl -w
use Foo;
eval { exit 0 };
warn $@ if $@;
print "ha!\n";
Foo.pm:
package Foo;
require Exporter;
@ISA = 'Exporter';
@EXPORT = 'exit';
sub exit { die @_ }
Returns:
# 0.
File ':Foo.pm'; Line 5
ha!
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-anyperl-request@macperl.org