I am trying to send a SIGHUP signal to an external process using PHP. Currently, I am doing the following:
$pid = shell_exec('ps -ef | grep mosquitto | grep -v grep | awk \'{print $2}\'');
shell_exec('kill -s HUP $pid');
When I run "php test.php" from the command line, I have verified that the signal is sent to the correct process, as expected.
When I invoke the script by visiting http://foo.com/bar/test.php, the signal isn't sent, and shell_exec returns nothing.
For testing, I temporarily ran PHP with root permissions but had the same issue, so I assume this is not a permission issue.
Interestingly, shell_exec returns output for the pwd command and the uptime command to the browser, but not the ls command. But when run from the command line, shell_exec returns output from ls normally.
Is there another limitation of these commands that I'm missing?
Also, a few notes:
- Safe Mode is off
- error_reporting = E_ALL
- No functions are disables
- I have tried explicitly pointing to the binaries (Ex. /bin/ps and sh -c ps)