in reply to IRC Client (non-bot)

Update: added Thread::Cancel solution.

I haven't used threads in perl (gotta try it sometime), but I'll take a wild stab at this....

okay, I've been playing with it, and determined that this is not a wild stab after all.

I noticed that you are using blocking I/O in your thread. $thread->join merely waits for the thread to terminate. I think the thread is blocking on I/O and thus not noticing that $die = 1.

As a quick fix, try sharing the thread's $sock variable, and adding close($sock) in your shutdown code (i.e. right after $die = 1;.) Basically, you have to find a way to wake up the thread from its I/O call. Another option is to send yourself a signal that is caught by the thread. Or, re-write your thread I/O to include a timeout so you can periodically check to see if it should exit.

I'm sure there are cleaner ways to do this. Like I said, I really should check out perl threads.

Update: The close($sock) probably won't work. If you don't care about cleanly shutting down the thread, just detach it and then call exit().

Update: Check out Thread::Cancel. It uses a signal to cancel threads. Very handy!