0

Oops. I have been trying to play around with some PayPal code and have inadvertently set an infinite loop of some sort going on my server. Any guidance on how to stop this code running would be much appreciated. The error log is quickly building up, every error is the same as follows:

PHP Warning:  feof() expects parameter 1 to be resource, boolean given in /home/myfirsti/public_html/work.php on line 3
[04-Jul-2013 00:44:38 Europe/London] PHP Warning:  fgets() expects parameter 1 to be resource, boolean given in /home/myfirsti/public_html/work.php on line 4

Many thanks.

Welly
  • 305
  • 6
  • 21

1 Answers1

4

It should stop when the execution time limit is reached, which is usually just a minute. However note that this time does not include file I/O, so the amount of time it takes to write the error log may be extending the length of the script.

It will stop eventually, but you should contact your host and ask them to kill the process.

To prevent it happening in future, always check if the resource is valid before passing it to feof()

(Note that I really wish the function were fneof instead "file not end of file" to prevent this kind of problem...)

Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592
  • @Rob W , I think that's exactly what's happened. I was hoping the timeout would be 60 seconds but it's been going a while now. For the moment I can keep deleting the error_log from the server but the file size is getting so huge if I don't keep doing this I'm going to massively bust my quota. Is there anything else I can do before I can call my host in the morning? – Welly Jul 03 '13 at 23:53
  • Wow, you have to wait until morning to call your host? I can call mine 24/7 and get maintenance on my servers in seconds ;) – Niet the Dark Absol Jul 03 '13 at 23:56
  • Actually, if I were you, I would just stop deleting the log file and let it build up. If they give you a hard time over it, tell them it's their responsibility to make sure the server is working, and if your script can cause a giant log file to eat up the entire server's hard drive, and it was left unchecked because you couldn't call them, then that's their fault. – Niet the Dark Absol Jul 03 '13 at 23:58
  • You read my mind @Kolink . The problem with the PayPal IPN system is that it can't be tested locally hence not realising I'd made this mistake until it was on the server ;) – Welly Jul 04 '13 at 00:00
  • Believe me, I've made the same mistake. But I can just log in and kill the process myself. It all depends on the host, of course, but I have to say the the one I use is the best in the world (and that's not an overstatement!) Not going to post the link here, but if you find my first game on my SO profile, you'll find out who our host is at the bottom. – Niet the Dark Absol Jul 04 '13 at 02:20