Name

SPVM::Go::OS::Signal - Signal Manipulation

Description

Go::OS::Signal class in SPVM provides a way to handle OS signals using channels.

Usage

use Go::OS::Signal;
use Sys::Signal::Constant as SIGNAL_C;
use Sys;

my $sig = Go::OS::Signal->new;

my $ch = Go->make(1);

$sig->notify($ch, SIGNAL_C->SIGTERM);

Sys->kill(SIGNAL_C->SIGTERM, Sys->process_id);

my $signal = $ch->read;

Constructor Methods

new

static method new : Go::OS::Signal ();

Creates a new Go::OS::Signal object.

Instance Methods

ignore

method ignore : void ($signal : int);

Ignores the signal $signal.

See Sys::Signal::Constant about the values of signals.

notify

method notify : void ($channel : Go::Channel, $signal : int);

Creates a goroutine to read the sent signal and write it to the $channel.

See Sys::Signal::Constant about the values of signals.

stop

method stop : void ($channel : Go::Channel, $signal : int);

Stops the signal handling for the signal $signal and the channel $channel.

See Sys::Signal::Constant about the values of signals.

reset

method reset : void ();

Resets all signal handlers and clears registered channels.

DESTROY

method DESTROY : void ();

Destructor. Calls "reset".

Copyright & License

Copyright (c) 2026 Yuki Kimoto

MIT License