I have a cgi script which, when user connects, starts to make simultaneous connections to different websites searching for some information. Because each thread has the same goal, I just detach it, and the function that is ran by the thread will call exit if the answer is found ending the perl process and all threads.
The problem is that if user disconnects, i.e. leaves the page before the answer is found, the script and all the threads will still be running.
This of course creates large overhead, so I was wondering if there is a way to check whether a user is still connected to the page?