Extract run_cgi(). No functional change intended.