CGI Programming / Scripts Question:

Download Job Interview Questions and Answers PDF

How can I run my CGI program live in a debugger?

CGI Programming Interview Question
CGI Programming Interview Question

Answer:

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.

Download CGI Programming Interview Questions And Answers PDF

Previous QuestionNext Question
What is a CGI bin directory?What is the difference between a CGI script and a CGI program?