I'm not quite sure that I understand why do you want execute foo from web page. But if you need to exec some long running operation from your web page you can do it by following algorithm:
- Create job queue (in the database, for example)
- Run foo by cron (every minute, for example)
- In your web page you just create new task with all needed parameters and store it the queue
- When foo find out uncompleted task it will process that task and store result code
I use this approach to send emails, copy result files to other servers (it's difficult to copy file using SSH via HTTP, for example).
Also, to improve processing of task you can use count of unsuccessful results and exclude from process list tasks which exceeded some limit.
---
Michael Stepanov aka nite_man
It's only my opinion and it doesn't have pretensions of absoluteness!