473,378 Members | 1,378 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Blocking read on pipes

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

Jul 18 '05 #1
0 1167

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Christian Hammers | last post by:
Hello I would like to call a unix shellscript from within a PHP script and - write data to its STDIN - read data from its STDOUT *and* STDERR - get its exit code afterwards proc_open seems...
4
by: Jonathan Fine | last post by:
Hello I have written a program that interacts with a command line program. Roughly speaking, it mimics human interaction. (With more speed and accuracy, less intelligence.) It works fine...
2
by: Robin Becker | last post by:
I'm using a polling loop in a thread that looks approximately like this while 1: p = find_a_process() rc = p.poll() if rc is not None: out, err = p.communicate() #deal with output etc...
13
by: j. del | last post by:
I am just beginning to write programs... and my first task that I have set myself is to write a little program that will generate cryptic bywords from a source of text. A cryptic byword is...
3
by: Mario | last post by:
Hello, I couldn't find a solution to the following problem (tried google and dejanews), maybe I'm using the wrong keywords? Is there a way to open a file (a linux fifo pipe actually) in...
6
by: placid | last post by:
Hi all, I have been looking into non-blocking read (readline) operations on PIPES on windows XP and there seems to be no way of doing this. Ive read that you could use a Thread to read from the...
3
by: Tom Plunket | last post by:
I'm using subprocess to launch, well, sub-processes, but now I'm stumbling due to blocking I/O. Is there a way for me to know that there's data on a pipe, and possibly how much data is there so...
12
by: puzzlecracker | last post by:
is it even possible or/and there is a better alternative to accept input in a nonblocking manner?
5
by: Thomas Christensen | last post by:
This issue has been raised a couple of times I am sure. But I have yet to find a satisfying answer. I am reading from a subprocess and this subprocess sometimes hang, in which case a call to...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.