Jump to content


Photo

Stop PHP waiting for process to finish


  • Please log in to reply
4 replies to this topic

#1 sam2222

sam2222
  • Members
  • Pip
  • Newbie
  • 7 posts

Posted 20 March 2006 - 03:20 PM

Hello,

Is there a way to make PHP not wait for a process to finish when you start it from exec? or is there any other ways to start a process from PHP and for PHP not to wait?

Thanks,
Sam

#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 20 March 2006 - 03:23 PM

Can you explain why you want this to happen?

Ken

#3 sam2222

sam2222
  • Members
  • Pip
  • Newbie
  • 7 posts

Posted 20 March 2006 - 03:27 PM

Thanks for your reply.

Well I want the process to run in the background and do somethings that will take a while and I don't want the script to be loading for all the time. I've got the process to run in the background now I just can't get PHP to stop waiting for it to finish.

Thanks,
Sam

#4 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 20 March 2006 - 03:35 PM

You could look at the [a href=\"http://www.php.net/pcntl_fork\" target=\"_blank\"]pcntl_fork[/a]() function and do the exec in the forked procedure. That script would wait for the execed procedure to finish before ending. You main script would have to wait until the forked script finishes before ending, but that could be at the very end of the script.

I've never used this myself, so YMMV.

Ken

#5 sam2222

sam2222
  • Members
  • Pip
  • Newbie
  • 7 posts

Posted 20 March 2006 - 03:38 PM

Thanks! I will have a look at that.

Thanks,
Sam




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users