Seems to me a thread can exit in one of three ways.
By throwing an exception.
$ perl -Mthreads -e'my $t = async { die "Foo" }; $t->join; say "done"' Thread 1 terminated abnormally: Foo at -e line 1. done
This isn't silent.
By returning.
$ perl -Mthreads -E'my $t = async { "code" }; $t->join; say "done"' done
You can detect this as follows:
$ perl -Mthreads -E'sub t { "code" } my $t = async { t(); warn("return +ed"); }; $t->join; say "done"' returned at -e line 1. done
By calling threads->exit
$ perl -Mthreads -E'sub t { "code" } my $t = async { threads->exit(); +}; $t->join; say "done"' done
You can detect this as follows:
$ perl -Mthreads -E'my $o = \&threads::exit; *threads::exit = sub { wa +rn "exit"; $o->(@_) }; my $t = async { threads->exit(); }; $t->join; +say "done"' exit at -e line 1. done
Another possibility is that your thread isn't responding because it's blocked, not because it exited. What makes you think it died?
In reply to Re: Why do my threads sometimes die silenty?
by ikegami
in thread Why do my threads sometimes die silenty?
by alain_desilets
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |