View Single Post
Old Jan 18th, 2008, 9:58 AM   #8
grimpirate
King of Portal
 
grimpirate's Avatar
 
Join Date: Sep 2005
Posts: 431
Rep Power: 4 grimpirate is on a distinguished road
Send a message via Yahoo to grimpirate
Re: register_shutdown_function() not behaving as expected

Well I couldn't output the connection_status() result to a file, buuuuuut I modded the code to
<?php
// Running on a Windows XP machine with an Apache server
error_reporting(E_ALL);

ignore_user_abort(false); // Does indeed affect behavior now

function cleanup($filename){
	switch(connection_status()){
		case 1:
		unlink($filename);
		case 2:
		case 3:
		break;
	}
}

$filename = tempnam(getcwd(), 'tmp');

register_shutdown_function('cleanup', $filename);

set_time_limit(5);
// Purposely causes a CONNECTION_TIMEOUT
do{
	echo 'foo';
}while(true);
?>
This unlinks the file if a CONNECTION_ABORT happens, but does not unlink the file if a CONNECTION_TIMEOUT or a CONNECTION_TIMEOUT & CONNECTION_ABORT happen simultaneously. Thanks a lot for the help Sane. It seems you were onto something about the browser output thing. My previous code was in fact deleting the file but I guess it deleted it after the machine returned from sleep().
__________________
Lo, there do I see my father. 'Lo, there do I see My mother, and my sisters, and my brothers. 'Lo, there do I see The line of my people... Back to the beginning. 'Lo, they do call to me. They bid me take my place among them. In the halls of Valhalla... Where the brave... May live... ...forever.. GrimBB | Mimesis
grimpirate is offline   Reply With Quote