Thank you for your help, Nik! I was actually trying to write up some sort of
server that will send out lock requests to a bunch of remote clients and
listen for responses, and then decide which course of action to take based
up the responses. I was just wondering what would be a good way to
synchronize the actions from the clients so as not to create any race
condition or deadlock. This is getting nasty...
Yi
-----Original Message-----
From: Nikolai Devereaux [mailto:yomama@u...]
Sent: Monday, July 02, 2001 6:34 PM
To: professional php
Subject: [pro_php] RE: interrupt handling in PHP
> Would anyone happen to know how to do interrupt handling in PHP?
> Say I hit a button so the script went out somewhere to fetch the
> data requested, but I changed my mind and hit 'cancel' to revoke
> it. Would such a cancellation be handled as interrupt the same
> way Ctrl-C is by Unix? Or is there any get-around to achieve the
> same result, namely, an aborted action.
Hello,
I don't know if there's a standard default action in PHP to handle this. I
wrote a simple test.php file (below) which seemed to give me some insight to
what happens...
--------------<test.php>--------------
<?php
$fp = fopen("testing.txt", "a");
for ($i = 0; $i < 100000; $i++) // loop for a while...?
{
fwrite($fp, $i . ":\t" . microtime() . "\n");
}
fflosh($fp);
fclose($fp);
?>
<html>
<body>
Done. Didn't hit cancel/stop fast enough.
</body>
</html>
--------------</test.php>--------------
Having a form who's action="test.php" immediately blanks the screen as the
server is processing the new page to be displayed, so the cancel button does
not appear. However, hitting the STOP button of the browser seems to just
stop the script wherever it was running at the time. If you don't stop the
script, then the file "testing.txt" has 100000 lines in it, and the browser
will display the "Done. Didn't..." message.
I don't think that there's any sort of exception handling built into PHP, so
you can't have a script continue to process once the user has stopped
execution.
Hope this helps,
Nik