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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.