moejoe22 Posted December 7, 2008 Share Posted December 7, 2008 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. Quote Link to comment Share on other sites More sharing options...
JonnoTheDev Posted December 8, 2008 Share Posted December 8, 2008 exec should work as long as you are using the full correct path. exec('/path/program', $output); Also has your CLI program got the appropriate permissions for php to execute it? If you are on a shared host then they may have disabled the use of exec(). Quote Link to comment Share on other sites More sharing options...
moejoe22 Posted December 9, 2008 Author Share Posted December 9, 2008 Yes, I can use system, exec to run simple commands like echo or execute simple scripts. I think the problem is that the c/c++ program has different ownership while the php has ownership of apache.. I don't know how to get apache to send a signal to a program that it doesn't own. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted December 9, 2008 Share Posted December 9, 2008 Are the shell scripts really in the same folder as your PHP script? You have ./ in front of the path, which would mean that it HAS to be in the same folder or deeper. If it's in like, ~/bin, then use a full path or hope that you have nothing else with the same name in your PATH. Quote Link to comment Share on other sites More sharing options...
moejoe22 Posted December 9, 2008 Author Share Posted December 9, 2008 Yep same folder, I will move later for security reasons.. now I just want them to work. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted December 9, 2008 Share Posted December 9, 2008 What OS are you running? It's very strange that this isn't working for you, because I just tried pgrep from PHP and it worked just fine. Maybe it's some php.ini setting that I don't know about, but idk. Do you have access to your php.ini? Quote Link to comment Share on other sites More sharing options...
moejoe22 Posted December 9, 2008 Author Share Posted December 9, 2008 It's a linux server, I don't know the version.. I also don't own the server. Yes, I have it, which setting would you like to view? Quote Link to comment Share on other sites More sharing options...
DarkWater Posted December 9, 2008 Share Posted December 9, 2008 safe_mode and safe_mode_exec_dir. Quote Link to comment Share on other sites More sharing options...
moejoe22 Posted December 9, 2008 Author Share Posted December 9, 2008 safe_mode Off Off safe_mode_exec_dir no value no value Quote Link to comment Share on other sites More sharing options...
DarkWater Posted December 9, 2008 Share Posted December 9, 2008 That's weird then. I'll get back to you tomorrow; I need to go. Quote Link to comment Share on other sites More sharing options...
JonnoTheDev Posted December 9, 2008 Share Posted December 9, 2008 Make sure the program file has the correct permissions. Doesnt matter about ownership. Use chmod. Quote Link to comment Share on other sites More sharing options...
moejoe22 Posted December 10, 2008 Author Share Posted December 10, 2008 Yea, it has +x permissions. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.