PHP CLI in Windows: Handling Ctrl-C commands?
问题 How can I handle CTRL + C in PHP on the command line? Pcntl_* functions do not work in Windows. 回答1: As of PHP 7.4, this is now possible by registering a handler callback with the sapi_windows_set_ctrl_handler function. This is complemented by the sapi_windows_generate_ctrl_event, which can be used to dispatch signals to other processes attached to the same console as the caller. Only the CTRL-C and CTRL-BREAK events can be handled in user space, the close/logoff/shutdown events cannot be