wget --spider and ignore_user_abort(TRUE)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi there,

I am trying to get a script to run in background no matter what, but I am 
obviously doing it wrong.

Here is the entire code:

<?php
//first instruction to be sure it is parsed
ignore_user_abort(TRUE);
set_time_limit(3600);

//sleep(10);

//this will send the HTTP code + headers + test
ob_start();
echo "test";
ob_flush();

sleep(10);
system("touch /tmp/aborting");
?>

The file /tmp/aborting get touched if I abort the connection in a 
browser, or if I run "wget blabla/script.php" and kill wget... in fact it 
works perfectly in any way, but it doesn't work when I use the "--spider" 
option of wget.

That option does a HEAD request and as soon as it receives the HTTP code 
200 closes the connection. The script is then aborted and the file
/tmp/aborting never get touched.

I initially thought that ignore_user_abort() never get to be parsed 
because the connection is closed before and I set it in the php.ini file, 
but that didn't work.
I then realized that PHP has to get at least to the ob_flush() call, 
that's proved by putting a sleep(10) just before the ob_start() call: 
wget --spider waits 10 seconds before exiting.

Why is ignore_user_abort(TRUE) ignored, what am I missing?
I probably shouldn't say that while asking for help, but... is this a bug?

I am using PHP 5.2.6-pl7-gentoo via Apache 2.2.9-r1 (Gentoo) with 
"worker" MPM.

Thank you for your help,
tillo

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux