|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22452 Background script stalls after 300 seconds
Submitted: 2003-02-27 05:50 UTC Modified: 2003-03-09 19:16 UTC
From: mikan at playcollective dot com Assigned:
Status: No Feedback Package: Scripting Engine problem
PHP Version: 4.3.0 OS: Linux (RedHat 7.2)
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: mikan at playcollective dot com
New email:
PHP Version: OS:


 [2003-02-27 05:50 UTC] mikan at playcollective dot com
I've been developping a daemon-script that runs in the background, after being spawned from the parent script.

i use an:

//  we are parent. spawn child and exit.
    $sock = fsockopen (getenv("SERVER_NAME"), 80);
      echo "ERROR: $errstr ($errno)\n";
    } else {
      if(socket_set_blocking($sock, false)){
        fputs($sock, "GET ".getenv("REQUEST_URI")."?child=1 HTTP/1.1\n");
        fputs($sock, "Host: ".getenv("SERVER_NAME")." \n");
        fputs($sock, "Connection: close\n\n");
    } else {
      echo "ERROR: blocking socket. execution halted.\n";

to spawn the child process (fork is not supported on the system this script is developed for). this code essentially opens a non-blocking socket to itself, with the variable child=1, and exits. the child process is now running.

this child process starts with:

  set_time_limit (0);

to be able to run "forever"...
after this it goes into an eternal while loop.

now, the problem is the following: if nothing happens within the loop (e.g. no output is produced, the script only checks and sleeps) the script halts (but doesn't die/exit) after exactly 300 seconds. the process still exists in the process list on the server.

if the script produces an non-fatal error within every 300 seconds, it continues running happily for hours and hours and hours.

i tried outputting a "boo" message using echo "boo"; every ten seconds, and that didn't seem to work. i tried flushing after echoing, that didn't work either. now i free a mysql-result that doesn't exist, and that DOES work!


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-03-09 19:16 UTC]
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.

PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Thu Dec 01 23:05:54 2022 UTC