我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

CLI中的PHP SIGTERM

I'm running php scripts from CLI, and i'd like to execute a function when script stopped with ctrl + c. I tried this:

<?php

declare(ticks = 1);

function sigint() {
    echo 'This is the end';
    exit;
}

pcntl_signal(SIGTERM, 'sigint');

$i = 1;

do {

    echo $i++ . ' ';

    sleep(1);

} while (TRUE);

but it doesn't works. How can i do this?

When attaching the handler in pcntl_signal, use SIGINT instead of SIGTERM

近期文章

  • 计算机专业开学 性价比电脑推荐
  • tomcat cors跨域问题
  • rpm包安装后修改版本号
  • VS2019运行时报错,同样代码在别的机子正常运行,本地报错
  • 在服务中拉起进程在关闭进程产生未关闭无效句柄
  • 嗯… 无法访问此页面已重置连接。 请尝试: 检查连接 检查代理和防火墙 运行 Windows 网络诊断 ERR_CONNECTION_RESET
  • 核显黑屏外接显示器有显示,独显正常
  • dev c++代码运行无结果
  • maven集中管理依赖版本出现的问题
  • minio 怎么更新bucket
  • 从SQL Server 2012和PHP填充的动态表中的额外行
  • Android studio 开发
  • linux安装dingo安装不上
  • minio 怎么更新bucket
  • vocode的JavaScript代码格式
  • VS2015远程调试无法连接
  • 华为手机进unity就闪退
  • 运用c语言,指针函数如何解
  • 移植单片机菜单,编译错误
  • 可视化大屏放到电视上样式乱了

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华