I have a php script that runs in the background 24/7. I have to interrupt it sometimes, and the point of the script is to cache transaction data in memcahced from bitcoin RPC (if you don’t know what it is, it doesn’t matter). I want a script to execute a function when a program receives a signal sent to ^ C (C control).
You probably want to pcntl_signal. The signal you need to catch is SIGINT.
pcntl_signal
SIGINT
If someone else is looking, I found an answer that does not require pcntl_signal.
system("stty intr ^-");, ^C script . ord(fread(STDIN, 1)) == 3 PHP .
system("stty intr ^-");
^C
ord(fread(STDIN, 1)) == 3
, .