2

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.

Sammitch
  • 30,782
  • 7
  • 50
  • 77
  • You could put a shell script on remote machine which kills the process(es) you want to kill (just pass the PID to the script, e.g. `$ myKill.sh -id NNN` ). Then just execute that script via php/ssh. –  May 01 '14 at 19:21

1 Answers1

3

You can sending signals via PHP :

posix_kill(posix_getpid(), SIGTERM); 
Alin Dobra
  • 46
  • 3