I am trying to get php to send a signal to a concurrently running c/c++ program. I have tried several ways of attempting this but every time the php route fails. I can from terminal send the appropriate signal and the c/c++ program(s) will acknowledge receiving the signal (I have custom handlers written for them) but when I try through php it does nothing. Here's an example of some of the things I've tried: $y = `./sendsig`; system("./sendsig", $x); system("./sikil", $z); exec("./sendsig"); sendsig is a shell script I wrote that when run from terminal sends the right signal to the c/c++ prog and the program acknowledges the signal. $y = `./siint`; system("./siint", $x); system("./siint", $z); exec("./"siint); siint is another c program that I wrote that sends the right signal to the c/c++ program and it acknowledges the signal being received (only when I run siint from terminal.. from php it blunders). $pid = `pgrep ex`; // this line doesn't work atm so I have $pid set by hand to the process of the c/c++ program $y = `kill -10 $pid`; system("kill -10 $pid", $x); exec("./sendsig"); Is the direct route I tried getting php to send the signal itself, and that didn't work at all. Does anyone have any ideas? I'm running out of options to get php to send a signal to a program.
You didn't say how you were running the PHP... is it via a browser or via the command line? All of the following pertains to if you are running it via the browser: 1) Make sure the web server user has permissions to run the various scripts. 2) Especially when it comes to exec type functions, make sure you check the various safe mode options as PHP is very particular when it comes to all of that. 3) On your exec line, add a 'set path' type command line call first. I had problems with some apps running from the command line without actually knowing the paths to look in. Sorry if that's not very helpful... it will hopefully get you some of the way, at least.
Yes, the script is running via a browser. I can run simple scripts like.. echo "hello world" and inside php do $s = `./hello`; echo "$s"; That will work.. just not signals. Thanks for the input.