//模拟了服务器端 httpd 进程启动 cgi的过程,
//完整展现了 get,post 方法支持
//gcc -g httpd_all.c -o httpd_all.ums;
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/wait.h>
#include <stdlib.h>
#define CGI_NAME "get_post.ums"
#define REQUEST_METHOD "REQUEST_METHOD=POST"
#define REQUEST_PARAMETER "myname=huangzhihui"
int main(int argc, char *argv[])
{
int parent[2],child[2];
if (pipe(parent) < 0)
{
printf("create pipe fail.\n");
}
if (pipe(child) < 0)
{
close(parent[0]);
close(parent[1]);
printf("create pipe fail.\n");
}
pid_t pid;
if ((pid = fork()) < 0)
{
printf("fork fail.\n");
}
else if (pid > 0)
{
/* pa