Sending signals to a process opened by proc_open()

末鹿安然 提交于 2019-12-11 03:28:46

问题


We've got a utility here that's using proc_open() to call ssh to run commands on a remote machine. However, in some cases we need to halt the command on the remote machine but proc_close() and proc_terminate() do not cause the desired signal to be sent through to the far side of the ssh connection. SSH will generally issue a SIGHUP to running programs when it is terminated, but we need to send a SIGINT to ssh which will forward it through to the program running on the remote end.

I've googled as much as I can, and there seem to be a number of pcntl functions for receiving signals, but I have not been able to find anything about sending signals via PHP, let alone anything related to proc_* functions.


回答1:


You can sending signals via PHP :

posix_kill(posix_getpid(), SIGTERM); 


来源:https://stackoverflow.com/questions/23414704/sending-signals-to-a-process-opened-by-proc-open

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!