in reply to Re^2: Exiting a script with an 'infinitely looping' thread
in thread Exiting a script with an 'infinitely looping' thread
A quick note: Detaching the thread doesn't cause it to exit cleanly, just silently.
#!/usr/bin/perl use threads; DESTROY { print "Destroyed\n" } sub test { my $x = bless({}); sleep() while 1; } $SIG{INT} = sub { exit }; my $thread = threads->create('test')->detach(); print("Press Ctrl-C to exit\n"); sleep();
If the thread exited cleanly, the above prints Destroyed. It doesn't.
|
|---|