How can I run my CGI program live in a debugger?
Submitted by: Administrator
At First,in the CGI code, at it is start, add "sleep(30);". This will cause the CGI to do nothing for thiry seconds (you may need to adjust this time). Compile the CGI with debuging info ("-g" in gcc) and install the CGI as normal. Next, using your web browser, activate the CGI. It will of course just sit there doing nothing. While it is sleeping, find it is PID(ps -a | grep <cgi name>). Load your debugger and attach to that PID("attach <pid>" in gdb). You will also need to tell it where to find the symbol definitions ("symbol-file <cgi>" in gdb). Then set a break point after the invocation of the sleep function and you are ready to debug. Do be aware that your browser will eventually timeout if it does not receive anything.
Submitted by: Administrator
Read Online CGI Programming Job Interview Questions And Answers