in reply to system or exec in a web environment

The other monks are correct, 'exec' never returns. Never.

I would suggest changing the CGI script to give the user a message like "Your file is being processed" and just end.

Then in the background, you need a listener program that watches that directory for new files, picks them up in turn, and processes them. The one I wrote is a shell-script that runs a Perl script every 10 seconds, and is started by rc.local. If you want it to process multiple files at a time, a thread pool can be your friend.

If you need to keep users informed about how their files are going, a CGI script that displays results from a status table, updated by the worker threads, might make sense. (You could even make it part of the original script with a refresh, if you want that 'interactive application' style.)

--
Spring: Forces, Coiled Again!
  • Comment on Re: system or exec in a web environment