in reply to Re^8: Exiting a script with an 'infinitely looping' thread
in thread Exiting a script with an 'infinitely looping' thread

If detach doesn't work with older perls does that mean I have to resort to using a shared variable to tell the thread to exit? I'd really like to avoid doing that if possible.

You apparently have no problem with killing the threads ungracefully (->detach()). If you have no problems killing the main thread ungracefully either, just use POSIX::_exit instead of exit.

#!/usr/bin/perl use threads; use POSIX qw( _exit ); sub worker { sleep() while 1; } $SIG{INT} = sub { _exit(0) }; my $thread = threads->create('worker')->detach(); print("Press Ctrl-C to exit\n"); sleep() while 1;