mkfifo?
两个小程序,注释部分和原来的语句有什么不同,mkfifo第一个参数有要求吗?为什么用注释的就不能把字符串传过去?
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
int main()
{
int fd;
char str[12]="hello world";
mkfifo("fifoa",O_CREAT|O_EXCL); //mkfifo("fifo",O_CREAT|O_EXCL);
fd=open("fifoa",O_WRONLY); //fd=open("fifo",O_WRONLY);
write(fd,str,12);
sleep(1);
close(fd);
return 0;
}
******************************************
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
int main()
{
int fd;
char str[12];
fd=open("fifoa",O_RDONLY); //fd=open("fifo",O_RDONLY);
memset(str,0,sizeof(str));
read(fd,str,12);
write(STDOUT_FILENO,str,12);
close(fd);
return 0;
}
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
int main()
{
int fd;
char str[12]="hello world";
mkfifo("fifoa",O_CREAT|O_EXCL); //mkfifo("fifo",O_CREAT|O_EXCL);
fd=open("fifoa",O_WRONLY); //fd=open("fifo",O_WRONLY);
write(fd,str,12);
sleep(1);
close(fd);
return 0;
}
******************************************
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
int main()
{
int fd;
char str[12];
fd=open("fifoa",O_RDONLY); //fd=open("fifo",O_RDONLY);
memset(str,0,sizeof(str));
read(fd,str,12);
write(STDOUT_FILENO,str,12);
close(fd);
return 0;
}
...全文
相关推荐
mkfifo.rar_进程与线程_C/C++_
在这个名为"mkfifo.rar"的压缩包中,包含了一个名为"mkfifo.cc"的源代码文件,这通常意味着它演示了如何使用`mkfifo()`函数创建命名管道(FIFO)。
mkfifo命令 创建FIFO文件
在Linux系统中,`mkfifo`命令是一个用于创建FIFO(First-In-First-Out,即先进先出)文件的实用工具,它是一种特殊类型的命名管道,常用于进程间的通信。FIFO文件允许一个进
mkfifo.rar
本文介绍了一个简易的管道通信程序的实现方法。程序通过创建和打开命名管道(FIFO),允许用户输入数据并写入管道。当用户输入'quit'时,程序结束通信并关闭管道。同时,程序也能从管道读取数据并输出到标
node-named-pipe:Linux在NodeJS中命名管道(mkfifo)
本文介绍了一个ESLint配置文件,支持ES6和Node.js环境,遵循eslint:recommended规则集,并设置了特定的代码风格规则。同时,详细描述了一个Node.js程序,该程序能够创建F
ReadFlag:解决ctfs中的一些readflag情况
首先,通过捕获SIGALRM信号执行命令获取flag;其次,使用mkfifo创建管道与子shell交互;再者,PHP代码利用proc_


