grimpirate Posted January 17, 2008 Share Posted January 17, 2008 I want to delete a file on any of the connection_status() conditions, be they CONNECTION_NORMAL, CONNECTION_ABORTED or CONNECTION_TIMEOUT or both abort and timeout. However, right now the function is only executing on normal and timeout and does nothing for aborted, any suggestions as to how to remedy this? <?php // Running on a Windows XP machine with an Apache server error_reporting(E_ALL); ignore_user_abort(false); // Tried both true and false neither seem to affect the behavior function cleanup($filename){ unlink($filename); } $filename = tempnam(getcwd(), 'tmp'); register_shutdown_function('cleanup', $filename); // Purposely causes a CONNECTION_TIMEOUT set_time_limit(20); sleep(30); ?> Quote Link to comment https://forums.phpfreaks.com/topic/86546-solved-register_shutdown_function-behaving-unexpectedly/ Share on other sites More sharing options...
grimpirate Posted January 18, 2008 Author Share Posted January 18, 2008 Never mind, I managed to get it working. <?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){ echo 'bullcrap'; 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); ?> Quote Link to comment https://forums.phpfreaks.com/topic/86546-solved-register_shutdown_function-behaving-unexpectedly/#findComment-442820 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.