innmind/signals

Manage multiple callbacks per signal

Maintainers

👁 Baptouuuu

Package info

github.com/Innmind/Signals

Homepage

Issues

pkg:composer/innmind/signals

Statistics

Installs: 103 157

Dependents: 4

Suggesters: 0

Stars: 0

5.0.0 2026-02-07 13:52 UTC

Requires

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT e8fd3d7d21d657bee0a4f677d7f2de1f9b5bca73

  • Baptiste Langlade <baptiste.langlade.woop@hey.com>

clisignalhandler

This package is auto-updated.

Last update: 2026-06-15 13:18:08 UTC


README

👁 CI
👁 codecov
👁 Type Coverage

Small abstraction on top of pcntl_signal to allow to register multiple callables for a single signal.

Installation

composer require innmind/signals

Usage

use Innmind\Signals\{
 Handler,
 Signal,
 Info,
};

$handler = Handler::main(); // automatically enable async signal on first `->listen()` call

$handler
 ->listen(Signal::interrupt, function(Signal $signal, Info $info): void {
 echo 'foo';
 })
 ->unwrap();
$handler
 ->listen(Signal::interrupt, function(Signal $signal, Info $info): void {
 echo 'bar';
 })
 ->unwrap();

// do some logic here

When above script is executed in a terminal and you do a ctrl + c to stop the process it will print foobar instead of stopping the script.

If for some reason you need to remove a handler (for example when a child process ended) you can call $handler->remove($listener)->unwrap() (remove the listener for all signals).