In Proc§

See primary documentation in context for method signal

method signal(Proc:D:)

Returns the signal number with which the external process was killed, or 0 or an undefined value otherwise.

In Supply§

See primary documentation in context for sub signal

sub signal(*@signals:$scheduler = $*SCHEDULER)

Creates a supply for the Signal enums (such as SIGINT) specified, and an optional :scheduler parameter. Any signals received, will be emitted on the supply. For example:

signal(SIGINT).tap{ say "Thank you for your attention"exit 0 } );

would catch Control-C, thank you, and then exit.

To go from a signal number to a Signal, you can do something like this:

signal(Signal(2)).tap-> $sig { say "Received signal: $sig" } );

The list of supported signals can be found by checking Signal::.keys (as you would any enum). For more details on how enums work see enum.

Note: Rakudo versions up to 2018.05 had a bug due to which numeric values of signals were incorrect on some systems. For example, Signal(10) was returning SIGBUS even if it was actually SIGUSR1 on a particular system. That being said, using signal(SIGUSR1) was working as expected on all Rakudo versions except 2018.04, 2018.04.1 and 2018.05, where the intended behavior can be achieved by using signal(SIGBUS) instead. These issues are resolved in Rakudo releases after 2018.05.

In Lock::ConditionVariable§

See primary documentation in context for method signal

method signal()

If and only if there are any threads that have previously waited on the condition variable, it unblocks at least one of them. Let's see how it works in this example:

constant ITEMS = 100;
for 1..15 -> $iter {
    my $lock =;
    my $cond = $lock.condition;
    my $todo = 0;
    my $done = 0;
    my @in = 1..ITEMS;
    my @out = 0 xx ITEMS;
    for 1..ITEMS -> $i {
        my $in = $i;
        my $out := @out[$i];
                    $out = $in * 10;
                        $cond.signal if $done == $todo;
                    } );
        } );
        $cond.wait({  $done == $todo } );
    say @out;

We are repeating 15 times the same operation: start 100 threads, every one of which modify a single element in an array. We protect the modification of a global variable, $done, and use signal to wake a up another thread to do its thing. This outputs the first elements of the generated arrays.

In Kernel§

See primary documentation in context for method signal

multi method signal(Kernel:D: Str:D $signal --> Int:D)
multi method signal(Kernel:D: Signal:D \signal --> Int:D)
multi method signal(Kernel:D: Int:D \signal --> Int:D)

Instance method returning the Signal numeric code for a given name for the Kernel object.

say $*KERNEL.signal("INT"); # OUTPUT: «2␤»