Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: own "mod_perl" implemenation

by esskar (Deacon)
on Jul 25, 2005 at 23:43 UTC ( [id://478019]=note: print w/replies, xml ) Need Help??


in reply to Re: own "mod_perl" implemenation
in thread own "mod_perl" implemenation

Okay; I finally got time to work on this issue. I looked at Die::Alive and Safe::World but this not quit what i want!
I wrote a C++ wrapper around the <edit>Perl-</edit> C-API which has a function to overwrite a internal perl funcion which looks like this:
static const char *CoreGlobal = "CORE::GLOBAL"; bool Interpreter::Overwrite(const char *funcname, const char *newfunc) { if(!gv_stashpv(CoreGlobal, 0)) return false; static size_t len_CoreGlobal = strlen(CoreGlobal); size_t len = strlen(funcname); size_t size = len_CoreGlobal + len + 16; char *fullfuncname = new char[size]; strncpy(fullfuncname, CoreGlobal, size); strncat(fullfuncname, "::", size); strncat(fullfuncname, funcname, size); GV *funcgp = gv_fetchpv(fullfuncname, TRUE, SVt_PVCV); GvCV(funcgp) = perl_get_cv(newfunc, TRUE); GvIMPORTED_CV_on(funcgp); delete [] fullfuncname; return true; }
now i can do something like the following
Interpreter perl; perl.Overwrite("exit", "Foo::bar");
which would substitute perl's exit with the function bar from the Foo package. (Not ensuring that Foo is already loaded!)
The question is now how to achieve the following:
Everytime the script calls "exit" (or possible die, or similar) my interpreter won't exit but the script stops running.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://478019]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-04-19 11:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found