posix_kill 与 pcntl_signal
这有点深奥,这个问题可能不会得到解答,直到我自己浏览源代码并回答它,但这里是:
我是一个简单的 PHP 守护程序库的作者:https://github.com/shaneharter/PHP-Daemon。虽然 PHP 对于此类事情并不理想,但有时人们需要在 PHP 中守护或编写 cron,并编写库以使“新手”更容易完成该任务。
我正在为该库实现 JavaScript Workers API,并且正在考虑添加对 POSIX 的依赖项(现在它正在使用 PCNTL 完成所有操作)。
有人知道 PCNTL_SIGNAL 和 POSIX_KILL 之间有什么区别吗?我可以使用其中任何一个向任何进程发送任何信号。那么……一个比另一个更好吗?或者他们实际上都在幕后做着同样的事情?
This is a bit esoteric and it's possible this question will go unanswered until I troll the the source myself and answer it, but here goes:
I'm the author of a simple PHP Daemon library: https://github.com/shaneharter/PHP-Daemon. While PHP isn't ideal for this sort of thing, sometimes people need to daemonize or write crons in PHP and wrote the library to make that task a lot easier on the "uninitiated."
I'm implementing the JavaScript Workers API for the library and I'm considering adding a dependency on POSIX (right now it's doing everything with PCNTL).
Does anybody know what the difference is between PCNTL_SIGNAL and POSIX_KILL? I can use either to send any signal to any process. So.... is one better than the other? Or are they both really doing the same thing under the hood?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
posix_kill()
用于向进程发送信号。pcntl_signal()
用于监听调用进程(您的脚本)接收到的信号。请参阅此处的示例。
posix_kill()
is used to send a signal to a process.pcntl_signal()
is used to listen for signals received by the calling process (your script).See the examples here.