李大神親筆:
1、項目:用命名管道實作簡單對話
2、思路:采用雙命名管道的形式來實作
3、代碼實作
#include <unistd.h>
#include <stdio.h>
int main(void)
{
int pipefd[2];
int ret;
ret = pipe(pipefd);
if(ret != 0)
{
printf("creat pipe failed\r\n");
return -1;
}
ret = fork();
if(ret == -1)
{
printf("creat child process failed\r\n");
return -1;
}
if(ret == 0)
{
//子程序
printf("123\r\n");
}
else
{
printf("35435\r\n");
sleep(1);
}
}
4、實作效果