Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Fast CGI termination

by enemyofthestate (Scribe)
on Sep 13, 2017 at 17:33 UTC ( #1199339=perlquestion: print w/replies, xml ) Need Help??
enemyofthestate has asked for the wisdom of the Perl Monks concerning the following question:

Never mind! I finally figured out that Apache sends a SIGTERM...

How does a Fast CGI program know that Apache is terminating it? AFAIK the basic process for Fast CGI is:

## Initialize stuff while (my $cgi = Fast::CGI->new) { # do something undef $cgi; } ## cleanup stuff
It is how to run the cleanup part that I cannot figure out. I tried a few tests (mostly just printing something to STDERR) and it looks like when Apache terminates the program the cleanup code never gets executed. So far there have been no problems attributable to the above but the code interfaces to a vendor supplied C library and, without being able to tell it to clean up after itself, I don't know what kind of junk it might leave laying about. I'd like to be clear on this before going to production.

Replies are listed 'Best First'.
Re: Fast CGI termination
by ikegami (Pope) on Sep 15, 2017 at 04:08 UTC

    How does a Fast CGI program know that Apache is terminating it?

    That question makes no sense. Apache doesn't terminate the FCGI daemon.

    It is how to run the cleanup part that I cannot figure out?

    In theory, you should never reach that code. `CGI::Fast->new` will only fail if there's a bug in the library or for OS errors such as accept failing.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1199339]
Approved by beech
help
Chatterbox?
[1nickt]: Discipulus I was sleeping in :-) It's a Holyday here. No work today. Just eating. Enjoy your day everymonk!

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (9)
As of 2017-11-23 14:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (336 votes). Check out past polls.

    Notices?