in reply to Re^5: killing threads inside forks
in thread killing threads inside forks
Again ,this code actually works good when sending USR1 signal , but it doesn't when I'm not sending any signal , it just reaches to :$SIG{USR1} = sub {shutdown = 1;}; foreach my $functions_name (@func_arr){ #Start new thread my $t = threads->create (sub{ &$functions_name(@parameters); $SIG{KILL} = sub { print "\ngot to thread killer\n\n"; threads->exit(); }; print "\ngot to end of thread\n\n"; #$shutdown = 1; }); push(@threads,$t); } sleep until $shutdown; if (my @remain = threads->list(threads::running)) { foreach (@remain) { if ($_ != $$){ $_->kill('KILL')->detach; } } $shutdown = 0; testProcess::prc_kill_handler(); } print "All threads exited normally."; my $index=0; foreach my $thread (@threads) #wait for all threads untill the end +and insert results to hash { $hash_results{$index}=$thread->join; $index++; } return %hash_results;
and then nothing happens. how can I handle that ? thanks again guys ! sorry if I'm not so clear again...print "\ngot to end of thread\n\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: killing threads inside forks
by BrowserUk (Patriarch) on Aug 02, 2013 at 04:18 UTC | |
by mojo2405 (Acolyte) on Aug 22, 2013 at 14:50 UTC |