Search code examples
c++capachefastcgimod-fcgid

fastCGI application code structure


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?


Solution

  • This question looks related, and might help you.