Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2002-06

Problem with AssignStream() on Linux

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Yet Another Geek

When I try to use AssignStream() to read more than 4096 bytes, my program hangs.

Not sure what is causing this, but seems to be
something of a "deadlock" situation -
the child will not continue writing until the buffer is flushed, and the parent
will not flush the buffer until the child is finished writing.

So both programs are stuck waiting on each other.

Does anyone know a workaround for this, or am I doing something wrong ?

__________________________________________________ Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

Reply by email

Michael Van Canneyt
to Yet Another Geek
Yet Another Geek wrote
When I try to use AssignStream() to read more than 4096 bytes, my program hangs.

That is because the piping mechanism uses a 4K memory buffer.

Show quoted text 7 lines
Not sure what is causing this, but seems to be something of a "deadlock" situation - the child will not continue writing until the buffer is flushed, and the parent will not flush the buffer until the child is finished writing.

This is correct.

Show quoted text 5 lines
So both programs are stuck waiting on each other. Does anyone know a workaround for this, or am I doing something wrong ?

Yes.
1. Use half the buffer size.
2. Use non-blocking IO - then your program will never hang, you'll get an EWOULDBLOCK error when there is no data available.

Michael.

Reply by email

Yet Another Geek
Show quoted text 5 lines
> When I try to use AssignStream() to read more than > 4096 bytes, my program hangs. 1. Use half the buffer size. 2. Use non-blocking IO - then your program will

never
hang, you'll get an EWOULDBLOCK error when there is no
data available.

Thanks for your respone, Michael -
Is there anywhere I can find an example of this?

__________________________________________________ Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

Reply by email