Question

I am writing a fastCGI application using the fastCGI development kit on Linux (Ubuntu), using Apache 2.2 + mod_fcgid.

According to the document, the correct code structure for an fastCGI app is:

  • Initialization section, which is executed only once.
  • Response loop section, which gets executed every time the FastCGI script gets called.

This seems to be wrong to me, surely, if there is an initialization section, then there must be a 'Cleanup' section?

If so, where would the cleanup section be, and how can I be sure that the cleanup section ever gets called - I mean is there something in the fastCGI protocol that tells the app to terminate?

Common sense tells me to place the cleanup section after the response loop - BUT is this the correct way to clean up?

Was it helpful?

Solution

This question looks related, and might help you.

OTHER TIPS

Normally when you are in the loop you will call "FCGX_Accept" function. If parent (apache) wishes to terminate FCGI child it will probably return "failure" for the accept function, in which case you should probably break the loop and cleanup on the way to exit.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top