Buffer problem on SunOS

G

gaool

Hello,

I wrote a python script (python 2.3.3) to send some commands to a
programm and to show on the screen the responses of this programm. I
use "Pipedream.py" module in my script to speak with the programm
(under unix system, it uses fdopen() to create a pipe and to send the
specified string. fdopen has a buffer size argument).So I can specify
a buffer size when I send a command with the pipedream module.

On windows it works but on SunOS I have a buffer problem (may be it
would be te same on other unix system...). I don't see the response of
my program before the buffer (which buffer?) is full.

I tried to put differents values for the buffer size argument of the
Pipedream object:
0 (which means unbuffered), 1 (line buffered), and other values (which
create a buffer with the size of the specified value).

But it's always the same thing: if the responses of the program are
short, nothing append. I have to send a lot of commands to full the
buffer. And then I can see all the responses of the commands I send
before and the last response of the last send command.

If the responses of the send command are big, it fill the buffer and I
can see as much lines of the response as the buffer size. And I don't
see the rest of my response.

Apparently, it doesn't depend on the buffer size argument of Pipedream
module.

In fact, it seems that there is a SunOS buffer but I don't know its
size and what I have to do to set it or to delete it.

If you have any idea...

Best regards.
 
D

Donn Cave

....
If the responses of the send command are big, it fill the buffer and I
can see as much lines of the response as the buffer size. And I don't
see the rest of my response.

Apparently, it doesn't depend on the buffer size argument of Pipedream
module.

In fact, it seems that there is a SunOS buffer but I don't know its
size and what I have to do to set it or to delete it.

I'm not acquainted with this "Pipedream" module, but you may
be interested to know that the UNIX operating system provides
a system level read(2) function that does not buffer any input.
If you apply this function to a pipe file descriptor, it will
return with whatever data was in the pipe, or block if there
is no data. That function is available in the posix module,
a.k.a. os module.

There's a pretty good chance however that it won't help, because
the data is indeed sitting in a buffer on the other side of the
pipe. That isn't a SunOS buffer per se, except inasmuch as it's
provided by the C stdio library functions that your application
probably calls for output. If it can be rewritten to flush its
output regularly, that will help. Otherwise the only thing you
can do is try to create a "pseudotty" instead of a pipe, because
standard buffering policy changes to line buffered on a tty.
There are modules for this, but you may find an openpty() function
in the posix module that will work for your purposes. In any case
this is not a simple solution, nor a cheap one in terms of system
resources.

Donn Cave, (e-mail address removed)
 

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

Similar Threads

buffer 14
Flushing buffer on file copy on linux 0
buffer 1
Check if buffer is empty from a given position 0
Lexical Analysis on C++ 1
Compile on SunOS? 1
Pcap network buffer 0
C pipe 1

Members online

No members online now.

Forum statistics

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

Latest Threads

Top