linux – 通过文件进行进程间通信
发布时间:2020-12-14 00:52:16 所属栏目:Linux 来源:网络整理
导读:当我在 Linux中的某些任意位置回应文件时,即echo / tmp / file,一些正在运行的进程响应.这个IPC是通过文件管道吗? 这是否意味着正在运行的进程始终打开要读取的文件?但是,如何编写文件,因为文件流是由自己的进程锁定的? 解决方法 如果你想使用一个文件与
当我在
Linux中的某些任意位置回应文件时,即echo> / tmp / file,一些正在运行的进程响应.这个IPC是通过文件管道吗?
这是否意味着正在运行的进程始终打开要读取的文件?但是,如何编写文件,因为文件流是由自己的进程锁定的? 解决方法
如果你想使用一个文件与另一个进程通信,你应该看一下man fifo.
我在这里只报告第一行: NAME fifo - first-in first-out special file,named pipe DESCRIPTION A FIFO special file (a named pipe) is similar to a pipe,except that it is accessed as part of the file system. It can be opened by multiple processes for reading or writing. When processes are exchanging data via the FIFO,the kernel passes all data internally without writing it to the file system. Thus,the FIFO special file has no contents on the file system; the file system entry merely serves as a reference point so that processes can access the pipe using a name in the file system. 我想这就是你需要的. 试想一下它是一个缓冲区.它必须通过不同的过程打开读取和写入.正在阅读的过程将被阻止,直到写入过程没有写入.当写入过程完成写入时,关闭文件,这是读取过程开始清空缓冲区的绿灯.它是一个FIFO,因此写入的第一行将是第一行读取.然后写作过程可以再次打开它们再次开始. 您可以使用mkfifo创建FIFO.看看男人mkfifo. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- linux – 为什么vsftpd的chroot_local_user不安全?
- 在 Ubuntu13.10 服务器中安装 Munin(监视工具)【转】
- linux – 光纤通道LUN重新扫描和QLogic
- linux – 了解docker端口映射
- linux – 在Oracle中,如何更改“默认”数据库?
- 搭建kickstart+pxe环境,为超微单节点服务器自动部署redhat7
- 存储 – Linux – 实际硬件RAID控制器调优(scsi和cciss)
- linux – tcpdump:“ethertype Unknown”?
- Linux下环境变量设置的三种方法:
- linux – 以非root用户身份运行的系统守护程序的PID文件的首