taskid); // task can't be stopped here sleep(6); $conn = connection::getInstance(); $running = true; while($conn && $running) { printf("hello world I'm task %s".PHP_EOL, $this->taskid); flush(); $sql = "SELECT status FROM task2 WHERE status='tostop' AND task_id=" . $this->taskid ; if($rs = $conn->query($sql)) { if($row = $conn->fetch_assoc($rs)) { // simulate bug : never ending task $running = false; } $conn->free_result($rs); } $conn->close(); unset($conn); sleep(5); $conn = connection::getInstance(); } printf("taskid %s ending.".PHP_EOL, $this->taskid); // task can't be (re)started here sleep(1); printf("good bye world I was task %s".PHP_EOL, $this->taskid); flush(); return 'stopped'; } } ?>