Due to Perl "safe signals", sleep is an uninteruptable opcode. Try it this way:
#!/usr/bin/perl -w use threads; $SIG{"INT"}=\&sigInt; my $thread=threads->create('test')->detach(); my $n = 100; 1 while --$n and sleep 1; sub test { my $n = 100; 1 while --$n and sleep 1; } sub sigInt { exit; }
In reply to Re^5: Exiting a script with an 'infinitely looping' thread
by BrowserUk
in thread Exiting a script with an 'infinitely looping' thread
by markseger
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |