in reply to Re: Catching signals under Linux
in thread Catching signals under Linux

Because you're likely to send the signal before the other thread was able to set the handler. Note that your output doesn't include 'in thread', which is printed before you set SIGHUP.

Replies are listed 'Best First'.
Re^3: Catching signals under Linux
by locked_user sundialsvc4 (Abbot) on Jan 29, 2010 at 18:17 UTC

    I have not looked closely at your code, but I would observe that the scenario just described is extremely common, and therefore extremely likely.

Re^3: Catching signals under Linux
by 7stud (Deacon) on Jan 29, 2010 at 11:29 UTC
    Yup:
    use strict; use warnings; use 5.010; use threads; sub thr_func { say 'in thread'; $SIG{'HUP'} = sub { say "signal caught" }; say 'doing some task...'; sleep 5; } my $thr = threads->create('thr_func'); sleep 2; $thr->kill('HUP')->join(); --output:-- in thread doing some task... signal caught
    Thanks.