I\'m trying to create a FIFO pipe between a python file and C file, but the issue is that when reading in the input from the C file, getline blocks until the writer end (in
yes ..forcing a flush will resolve the issue.
As immibis says in the comments, fifo.flush() solved my issue!
Your problem comes from the buffer. FIFO use block buffer by default. So the c program won't read anything until the write buffer of the fifo in python was full. And there's two way to change this behaviour:
there's three buffer mode:
What meet your needs here is the line buffer, so use fifo = open("emg", "w", 1);
instead of fifo = open("emg", "w");
will fix.
number 1 here instead line buffer. python doc
fifo.flush
after the write operation.