2017 © Pedro Peláez
 

library signal-handler

A library to ease the use of signal handling.

image

neutron/signal-handler

A library to ease the use of signal handling.

  • Wednesday, January 15, 2014
  • by romain
  • Repository
  • 2 Watchers
  • 8 Stars
  • 40,453 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 2 % Grown

The README.md

Signal Handler for PHP

Build Status, (*1)

A simple signal handler to manage incoming posix signals., (*2)

It is implemented as a singleton as pcntl_signal can only register one callback per signal., (*3)

Using this one, you can register as many callbacks per signal as needed., (*4)

For more information about signals, man signal., (*5)

// mandatory to listen to signals
declare(ticks=1);
$handler = Neutron\SignalHandler\SignalHandler::getInstance();
$handler->register(array(SIGINT, SIGTERM), function () { echo "stoppin !"; exit(); });
$handler->register(SIGCONT, function () { echo "all systems go..."; });

Register a signal handler

// register a handler for SIGCONT in default namespace
$handler->register(SIGCONT, function () { echo "SIGCONT received"; });
// register a handler for SIGCONT in "a namespace"
$handler->register(SIGCONT, function () { echo "SIGCONT received"; }, 'a namespace');
// register a handler for SIGCONT in "another namespace"
$handler->register(SIGINT, function () { echo "Interrupted !"; exit(); }, 'another namespace');

Unregister signals handler

Two ways are available to unregister signals., (*6)

By namespace :, (*7)

// unregister all handlers in "another namespace"
$handler->unregisterNamespace('another namespace');
// unregister all SIGINT handlers in "a namespace"
$handler->unregisterNamespace('a namespace', SIGINT);

By signal :, (*8)

// unregister all SIGINT handlers in any namespace
$handler->unregisterSignal(SIGINT);

License

This project is released under the MIT license., (*9)

The Versions

15/01 2014

dev-master

9999999-dev

A library to ease the use of signal handling.

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

signal

15/01 2014

1.0.1

1.0.1.0

A library to ease the use of signal handling.

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

signal

11/09 2013

1.0.0

1.0.0.0

A library to ease the use of signal handling.

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

signal