routine signal

Documentation for routine signal assembled from the following types:

class Supply

From Supply

(Supply) 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.

class Kernel

From Kernel

(Kernel) method signal

Defined as:

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␤»

class Proc

From Proc

(Proc) method signal

method signal(Proc:D:)

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