OS: ubuntu 11.10
Webserver: Apache
Code: PHP
Hello I am trying to “exec” a C code through PHP web page. When I run the same C code directly on terminal, it works fine, but when I “exec” it through PHP, I get a segmentation fault.
Any idea why such behavior? My C code is doing small “malloc”s at a few places. The code never the less works fine on directly executing through terminal using ./a.out
Is there a way for me to gdb the C code, when PHP tries to execute it?
Thanks
Hard to tell without actually seeing the code. Are you sure your program doesn’t leak? Are you able to add some debug console output to see when/where it crashes? Does your program try to access any ressources (like files, ports, etc.)? Are there sufficient rights for the web server’s user (or whoever runs the php script) to actually execute it properly?