I hope the replies above are helpful. This is not a situation that I've had to face, but looking at your code, and thinking about the situation in general, I wanted to raise some points:
- If the indenting is fixed in your code snippet (yes, proper indentation really helps), it looks like "end_html" is only invoked in the child, which seems wrong (but I'm not well acquainted with CGI scripts launching child processes and exiting cleanly).
- There's an "exit(0)", but only in the child, after the "exec" call, which of course does not return, so the "exit(0)" is never actually reached. (You say that "similar code" worked on a linux/apache setup -- I'd be a little surprised if this exact code snippet worked anywhere.)
- If the "fsscan" process is really heavy weight and lengthy, what would happen to your server if some clever hacker were to poke at this web page, say, 50 times in the span of one minute? Wouldn't you want some sort of safe-gaurd (e.g. a known pid file for the fsscan app when it's launched from the web) to keep from having multiple instances running at once?
There are other issues that I'd expect to arise, but again, I'm not that familiar with the issues... things like zombie processes (parents going away and leaving unreaped children behind).
On the whole, I'm thinking there must be a better way to actually run this process, other than launching it directly from a cgi script -- e.g. as suggested in a previous reply, you could have a cron process running every few minutes or so, to check whether a request has come in to run fsscan and if so, go ahead and run it (and don't accept any more requests until that run is finished). Then all the cgi script has to do is write some little file somewhere to indicate that such a request has been made.