⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 flush.c

📁 基于socket的简单通讯程序
💻 C
字号:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
#define SIZBUF 15

int main(void)

{
	char output[SIZBUF];
	pid_t pid,wpid;
	int wstatus;
	FILE *fp;
	
	printf("Content-Type:text/html\n\n");
   	printf("<head><title>AnHTMLPageFromaCGI</title></head>\n");
	printf("<body><br>\n");	
	printf("<H3>The Picture is as follows</H3>");

	pid = vfork ();

	if (pid < 0) {
		printf("fork: %m");
		wstatus = 0;
	} else if (pid) {
		do {
			wpid = wait (&wstatus);
		} while (wpid != pid && wpid > 0);
		if (wpid < 0) {
			printf("wait: %m");
			wstatus = 0;
		}
	} else {

		execl ("readsimple", "readsimple",(char*)0);
		printf("error execl return");
		exit (0);
	}
	printf("<p>vfork is finished!I am in parent pid</P>");

	fp=fopen("/home/www/out.dat","r");
	if(fp==NULL){
		printf("ERROR!Cannot open file !\n");
	}
	
	printf("<p>\n");
	while((fgets(output,SIZBUF,fp))!=NULL)
		printf("%s",output);
		
	printf("</p>\n");
	
	printf("</body>\n");
	printf("</html>\n");  
//	printf("\n<img src=\"/pic/shuai.gif\">\n");
	
	
   return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -