This is your code. Read it: it’s exactly what’s going to happen. No mysticism.
What’s going on? pledge(2) makes sure you’re only doing what you want to do: work with existing descriptors. The rest is just HTTP. Don’t want to work with HTTP? Use kcgi(3) or equivalent.
Want more examples? See Secure CGI Applications in C on BSD and Secure CGI.
httpd.conf(5) is so… simple. Server tells us the name. Listen tells us to listen. Location tells us a location. Where we have FastCGI. Relative to the root.
Don’t like FastCGI? Neither do we. But we’re not using it for this example: in the next snippet, we’ll use slowcgi(8) to invoke our CGI. So relax.
Want more examples? See Secure CGI Applications in C on BSD and Secure CGI.
Wow. Very configure. Compiles the script. Installs it. Makes sure slowcgi(8) and of course httpd(8) are running. Done.
Want more examples? See Secure CGI Applications in C on BSD and Secure CGI.