Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

posix_kill vs pcntl_signal

Tags:

php

posix

pcntl

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?

like image 705
Shane H Avatar asked Aug 30 '11 19:08

Shane H


1 Answers

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.

like image 51
Arnaud Le Blanc Avatar answered Oct 12 '22 23:10

Arnaud Le Blanc