Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Overwriting exit and similar

by esskar (Deacon)
on Jul 26, 2005 at 09:38 UTC ( #478109=perlquestion: print w/replies, xml ) Need Help??

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

Hi,
this is a following up question of the own "mod_perl" implemenation-node. I already posted this question there (Re^2: own "mod_perl" implemenation) but i think i got lost.

As you can see, i want to do a little speed up for my web scripts.
I wrote two applications a NamedPipe Server and a NamedPipe Client. The WebServer just calls the NamedPipe client as it would call the perl binary to run a cgi-script. The Client than connects to the NamedPipe Server which holds a number of precompliled instances of the script. I feed one instance with the data just received from the client and redirect the output back to client. It's quite fast. I'm running a catalyst application which is really fast no compared to CGI mode.


But if the script's calls exit, or die, the whole pipe-server shuts down. I know how to override perl internals (see the other node) but i want to achive that calling exit, die, ... really ends the script but not pipe-server.
So how do i have to implement myexit? Any ideas?

Replies are listed 'Best First'.
Re: Overwriting exit and similar
by Fletch (Bishop) on Jul 26, 2005 at 10:58 UTC

    Not to answer your problem, but it sounds like you've re-implemented a wheel, namely FastCGI.

    Update: And to answer your question, Apache provides its own Apache::exit sub. Things like Apache::Registry do a use Apache qw( exit ) so that its version is called rather than CORE::exit. (For mod_perl 1)

    --
    We're looking for people in ATL

      I know FastCGI, SpeedyCGI, ... but it's not what I'm looking for. I think they fork their processes anyway... but that is not what i want to do!
Re: Overwriting exit and similar
by jhourcle (Prior) on Jul 26, 2005 at 11:55 UTC

    The easiest way to trap die is to just put everything in an eval block. Also see die for info about what you can do with $SIG{'__DIE__'}.

    exit is a little trickier, but you might be able to set something up in an END block. (I've never tried, myself... I'm not sure what would happen if you did a goto in an END block). I'd think you'd be better off just removing calls to exit, or changing them to die where appropriate, if that's possible.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2023-02-05 20:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (32 votes). Check out past polls.

    Notices?