This general topic has come up before, here, here, here, and no doubt elsewhere on the internet as well. In my case, unlike these, the hang arises from a blocking socket that never gets a message, and perhaps that's why the solutions described there haven't worked for me. I'm developing in tandem a C++ app which communicates with the php script via a local socket connection, and when the C++ app crashes, it leaves the php script's socket waiting for a message that never comes. I've tried using session_destroy and session_unset (calling these first in a script before session_start) but they don't work; even quitting and restarting the browser doesn't help. I can only stop the session if I remove the session_start, reload the script and then end the session via the client. How can I kill the session without having to go through that?
Edit: I forget to mention, I also tried to time the socket out with
socket_set_option($socket,0, SO_RCVTIMEO, array("sec"=>1, "usec"=>0));
But I got an 'invalid operation' error, and it didn't work.
Edit 2: Setting a manual timeout, following the tip here, worked well enough. I still don't know how to, in general, kill a session that's e.g. stuck in an infinite loop, but oh well.