anshumangoyal has asked for the wisdom of the Perl Monks concerning the following question:
When this code is executing and Thread_SUB is sleeping and I press CTRL+C, the SIG{INT} is not triggered and thus the Print line in "INT_HANDLER' is not printed.use strict; use threads; my @threadsArr; $SIG{INT} = 'INT_HANDLER'; for (my $ii = 0; $ii < 10; $ii++) { my $Thread = threads->new( "Thread_SUB", $arg1, $arg2 ); push (@ThreadsArr, $Thread); } foreach (@ThreadsArr) { $_->join(); } sub INT_HANDLER { print "Received Interrupt, Stopping the Program.\n"; } sub Thread_SUB { my $arg1 = shift; my $arg2 = shift; print "$arg1 - $arg2\n"; sleep 200; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: CTRL+C Handling in Perl Threads
by zentara (Cardinal) on Nov 27, 2012 at 10:46 UTC | |
|
Re: CTRL+C Handling in Perl Threads
by remiah (Hermit) on Nov 27, 2012 at 10:09 UTC | |
by anshumangoyal (Scribe) on Nov 27, 2012 at 10:19 UTC | |
by remiah (Hermit) on Nov 27, 2012 at 10:54 UTC |