crunch/signal
Composer 安装命令:
composer require crunch/signal
包简介
process signal handling
README 文档
README
Simple process signal wrapper
Requirements
- PHP => 5.4
- ext-pcntl => *
Also ensure, that the pcntl_*() are not disabled via disabled_functions
php.ini-setting.
Usage
Waits ten seconds for a SIGTERM-signal.
use Crunch\Signal;
Signal\wait([Signal\TERM], function (Signal\Info $info) {
// Do something useful
}, 10);
Postpone certain signals
use Crunch\Signal;
$oldMask = Signal\block([Signal\TERM, Signal\HUP]);
// Some critical stuff
Signal\reset($oldMask);
A simple timer
use Crunch\Signal;
Signal\Timer(5);
Signal\wait([Signal\TERM, Signal\ALRM], function (Signal\Info $info) {
// Do something useful
}, 10);
Register a signal handler. declare(ticks=x) is required.
declare(ticks=1);
use Crunch\Signal;
require __DIR__ . '/../vendor/autoload.php';
echo posix_getpid() . PHP_EOL;
Signal\register(Signal\USR1, function (Signal\Info $info) { echo "USR1!"; exit; });
while (true) {
// very busy code
}
Contributors
See CONTRIBUTING.md for details on how to contribute.
- Sebastian "KingCrunch" Krebs krebs.seb@gmail.com -- http://www.kingcrunch.de/ (german)
License
This library is licensed under the MIT License. See the LICENSE file for details.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-01-10