PHP: what is pcntl_signal used for?

I found a piece of code that I had not seen before:

declare(ticks = 1);
pcntl_signal(SIGINT, array($this, "catchSignal"));
pcntl_signal(SIGTERM, array($this, "catchSignal"));

I looked at the function in the PHP documentation, but I still don’t understand what it is used for. Please help me understand why this is used, and some examples of where this should be implemented.

+3
source share
3 answers

The declare statement declares that it checks events for each tick. A tick is approximately equal to a line of code. This is used in PHP command line scripts so that you can interrupt interrupts and disable the script, rather than just killing it.

array($this, "catchSignal") pcntl_signal - ( ) "" . $this->catchSignal(), PHP . , "".

, script , $this->catchSignal() .

+5

signal . , , .

+3

, , , , . , , , - . , -C in * nix, . - , . , ; , .

pcntl_signal - PHP.

+3

Source: https://habr.com/ru/post/1769390/


All Articles