Sample Header Ad - 728x90

Redirecting fifo to python's stdin

1 vote
0 answers
237 views
$ mkfifo mypipe
$ echo "hello redirection" > mypipe
$ cat  mypipe
$ echo "hello redirection" > mypipe
However if I put python in a loop
# pyecho.py
while True:
    with open("/dev/stdin", "r") as f:
        print(f.read())
Then after the initial iteration (requiring two writes), it goes back to working as expected.
Asked by Tom Huntington (109 rep)
Apr 12, 2024, 02:42 AM
Last activity: Apr 12, 2024, 02:49 AM