I am currently trying to write a simple web server program in C++. The only problem that I have come across, so far, is that I would like my web server to be able to execute CGI (Common Gateway Interface) programs, but I'm not sure how to accomplish this.

I know that I need to be able to execute the CGI program and some how redirect the output of this program back to the network connection. I am thinking along the lines of using the exec system calls (execlp, execvp etc.) in some way.

If anyone could offer me some ideas, I would greatly appreciate it.

Thanks in advance,