Blocking read on pipes

  • Thread starter =?iso-8859-1?Q?Arnau_S=E1nchez?=
  • Start date
?

=?iso-8859-1?Q?Arnau_S=E1nchez?=

Hello,

I have a problem when reading from stdin (using it as pipe) in a Python program (the sender
is written in C):

C (sender)
write(1, buffer, 4)

Python (recv.py)
sys.stdin.read(256) or sys.stdin.read()

sender | recv.py

Python's read blocks the program because the written buffer length (4) is lower than the indicated
in read function (256), but when I do the same with C (read(0, buffer, 256)) it is not blocking,
just
returns the four bytes. That is what I need.

I've tried to flush the stdout in the sending program, but it does the same.

any ideas?

thanks,
arnau
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top