I am writing a basic http server in C. Handling a simple static .html file is easy but I have no idea how to handle dynamic .pl .cgi file extensions.

I know I will have to use exec() but how is my question?