In example below, we are going to use pcntl_signal function to let our command finish its job first and then exit. It is useful for preventing unexpected terminations which originate from ctrl+c action and kill PID command. We’ll be using a symfony command as an example.

Command

I will just print a message but you could use it for closing database connection, saving data, closing files, writing to a log file etc.

#php #symfony

Terminating running commands or processes properly with ctrl+c and kill command
1.70 GEEK