6

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?

Shane H
  • 3,263
  • 5
  • 26
  • 30

1 Answers1

11

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.

netcoder
  • 66,435
  • 19
  • 125
  • 142
Arnaud Le Blanc
  • 98,321
  • 23
  • 206
  • 194
  • Haha, wow. Great reality check. How did I get that in my head? It's one of those things -- 5 second glance at the docs (or my own code written 10 months ago) would've dispelled. A few weeks ago I was looking over the docs on PHP Semaphores, SEM, libevent, posix, etc, and I thought "Huh, why does POSIX extension implement a way to send signals, PCNTL has the same thing" -- And after that, it just became my own conventional wisdom. Anyway, thanks for taking a min to answer. Despite the ignorance of my question -- check out that daemon library if you ever have the need. It's really coming along! – Shane H Aug 31 '11 at 12:17