mkfifo

Why does my program hang when opening a mkfifo-ed pipe?

那年仲夏 提交于 2019-11-27 04:39:47
I use mkfifo to create a named pipe. Then I use the following program to open it. However, the program hangs at the line "fopen". Is there something wrong here? int main(int argc, char** argv) { char* line = "hello, world!"; FILE* fp = fopen("/tmp/myFIFO", "rw"); fprintf(fp, line); fclose(fp); return 0; } Try passing "w" as the mode to fopen. "rw" is not a valid mode argument for fopen , and even if it was, you probably don't want to both read and write to the FIFO in the same process (although it is possible, see below). As an aside, the correct mode argument for opening a file for both

Create a temporary FIFO (named pipe) in Python?

徘徊边缘 提交于 2019-11-27 01:25:38
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 exists when you run it on the files that mkstemp/NamedTemporaryFile have created. mhawke os.mkfifo()

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

Why does my program hang when opening a mkfifo-ed pipe?

白昼怎懂夜的黑 提交于 2019-11-26 12:45:35
问题 I use mkfifo to create a named pipe. Then I use the following program to open it. However, the program hangs at the line \"fopen\". Is there something wrong here? int main(int argc, char** argv) { char* line = \"hello, world!\"; FILE* fp = fopen(\"/tmp/myFIFO\", \"rw\"); fprintf(fp, line); fclose(fp); return 0; } 回答1: Try passing "w" as the mode to fopen. "rw" is not a valid mode argument for fopen , and even if it was, you probably don't want to both read and write to the FIFO in the same