in reply to Why does threads::join block SIGALRM

Hi CDahn,

I tried with MCE::Hobo. A Hobo is a migratory worker inside the machine that carries the asynchronous gene. Hobos are equipped with threads-like capability for running code asynchronously. Unlike threads, each hobo is a unique process to the underlying OS.

use strict; use warnings; use MCE::Hobo; sub worker { print "Worker thread started.\n"; while(1){} } my $hobo = MCE::Hobo->create(\&worker); print "Setting alarm.\n"; $SIG{ALRM} = sub { print "Alarm!\n" }; alarm 2; print "Joining.\n"; $hobo->join();

Output

Setting alarm. Joining. Worker thread started. Alarm!

Kind regards, Mario.

Replies are listed 'Best First'.
Re^2: Why does threads::join block SIGALRM
by marioroy (Prior) on Jun 07, 2016 at 17:03 UTC

    The behavior is similar with the forks module.

    use strict; use warnings; use forks; sub worker { print "Worker thread started.\n"; while(1){} } my $proc = threads->create(\&worker); print "Setting alarm.\n"; $SIG{ALRM} = sub { print "Alarm!\n" }; alarm 2; print "Joining.\n"; $proc->join();

    Output

    Setting alarm. Joining. Worker thread started. Alarm!

    Kind regards, Mario.