fifo

Create a temporary FIFO (named pipe) in Python?

六月ゝ 毕业季﹏ 提交于 2019-11-26 17:28:15
问题 How can you create a temporary FIFO (named pipe) in Python? This should work: import tempfile temp_file_name = mktemp() os.mkfifo(temp_file_name) open(temp_file_name, os.O_WRONLY) # ... some process, somewhere, will read it ... However, I'm hesitant because of the big warning in Python Docs 11.6 and potential removal because it's deprecated. EDIT : It's noteworthy that I've tried tempfile.NamedTemporaryFile (and by extension tempfile.mkstemp ), but os.mkfifo throws: OSError -17: File already

2019年8月9日星期五(系统编程)

家住魔仙堡 提交于 2019-11-26 17:15:53
2019 年 8 月 9 日星期五 一 . linux 多进程编程 - 通信方式。 1. 为什么进程之间要进行数据通信? 例子: ./test -> 开启一个名字为 test的进程。 ./project -> 开启一个名字为 project的进程。 通过学习通信方式,使得不同进程之间进行数据交换,例如 test进程发送数据给 project进程,从而控制 project进程运行状态。 2. 在 linux 下,通信方式有哪些?各自有什么特点? 以下几种方式属于系统编程的通信方式,只能同一台主机内部进程通信,不能跨主机。 1 )管道通信 管道通信分为有名管道与无名管道通信,管道也是 linux的一种特殊文件,进程可以写入数据到管道中,从而实现通信。 2 )信号 在 linux下,有非常多信号,例如暂停,继续,停止 ...,某一个进程通过发送信号给另外一个进程,从进行通信。 3 )消息队列 消息队列可以读取另外一个进程发送来的数据,而且可以读取特定的数据。 4 )共享内存 多个进程同时访问同一片内存空间。 能够跨主机通信的,只有网络编程才能实现 。 1 )套接字编程 可以实现不同的主机之间的通信。 二 . 进程之间通信 - 无名管道 1. 什么是无名管道?作用机制如何? 无名管道只能作用于亲缘关系的进程,例如父子进程。无名管道其实是数组来的,里面有读端与写端,进程只需要将数据写入

Named Pipes (FIFOs) on Unix with multiple readers

拟墨画扇 提交于 2019-11-26 16:05:23
问题 I have two programs, Writer and Reader. I have a FIFO from Writer to Reader so when I write something to stdin in Writer, it gets printed out to stdout from Reader. I tried doing this with TWO Readers open, and I got output to stdout from only one of the two Reader programs. Which Reader program Unix chooses to print stdout from seemed to be arbitrary each time I run this, but once it chooses one of the programs, each output to stdout gets printed from the same Reader program. Does anyone

forcing a program to flush its standard output when redirected

和自甴很熟 提交于 2019-11-26 14:09:04
问题 i have a closed source program that prints output to standard output. i need to parse the output. so i redirect the output to a fifo (from which i can read in the parent process that forks and execs the binary) using dup2 and then exec the program. the problem is that the fprintf calls in the file become buffered because it is now writing to a file. i tried calling setvbuf with _IONBF on stdout before calling exec. but the problem still exists. why does setvbuf not help in my case? how can i

Fixed size queue which automatically dequeues old values upon new enques

蓝咒 提交于 2019-11-26 01:06:52
问题 I\'m using ConcurrentQueue for a shared data structure which purpose is holding the last N objects passed to it (kind of history). Assume we have a browser and we want to have the last 100 browsed Urls. I want a queue which automatically drop (dequeue) the oldest (first) entry upon new entry insertion (enqueue) when the capacity gets full (100 addresses in history). How can I accomplish that using System.Collections ? 回答1: I would write a wrapper class that on Enqueue would check the Count

Fixed size queue which automatically dequeues old values upon new enques

最后都变了- 提交于 2019-11-26 00:58:07
I'm using ConcurrentQueue for a shared data structure which purpose is holding the last N objects passed to it (kind of history). Assume we have a browser and we want to have the last 100 browsed Urls. I want a queue which automatically drop (dequeue) the oldest (first) entry upon new entry insertion (enqueue) when the capacity gets full (100 addresses in history). How can I accomplish that using System.Collections ? Richard Schneider I would write a wrapper class that on Enqueue would check the Count and then Dequeue when the count exceeds the limit. public class FixedSizedQueue<T> {