spawn a process?

I need to write a CGI program that
can spawn a sub process. The sub
process is very time consuming. So I
want the CGI program to send browser a sub process id number and quit HTTP connection before the sub process finished.  

Later, user can check the status of the sub process by its id number.  This is under Unix. Is there some sample codes doing this?
yliu8Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TYoungCommented:
UNIX:

system("/programdir/bin/program &");

The & tells the starter that it can go on without it (dont wait).

I don't know how to get a system PID, sorry.
0
jhurstCommented:
fork() is the function that you need.  It creates a second copy of the process.  This second copy can do the work you want and the fork() returns the process id of the forked process.  The forked process knows that it is the forked one since its pid is the pid.  This process can then do whatever needs to be done while the original one send the required information to the user.

The one thing to be aware of is that many web masters restrict forked processes in the cpu cycles that they can use.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.