网站建设案例包括哪些,基于jsp的网站建设论文,衡水网站制作公司,h5婚纱摄影网站模板1、创建1个子进程2、程通过管道与子进程连接 子进程的标准输出连接到管道的写端主进程的标准输入连接到管道的读端3、进程中调用exec(“echo”, “echo”, “hello world”, NULL)4、进程中调用read(0, buf, sizeof(buf))#xff0c;从标准输入中获取子进程发送的字符串…1、创建1个子进程2、程通过管道与子进程连接 子进程的标准输出连接到管道的写端主进程的标准输入连接到管道的读端3、进程中调用exec(“echo”, “echo”, “hello world”, NULL)4、进程中调用read(0, buf, sizeof(buf))从标准输入中获取子进程发送的字符串并打印出来
code
#includestdio.h
#includeunistd.h
#includestdlib.h
#includesys/wait.h
int main(){pid_t pid;int fd[2];char buf[30];int count;int i0;pipe(fd);pidfork();if(pid0){perror(fork():);}if(pid0){dup2(fd[1],1);execlp(echo,echo,hello world,NULL);}else{dup2(fd[0],0);countread(0,buf,30);write(1,buf,count);}close(fd[0]);close(fd[1]);return 0;
}