[fpc-pascal]Problem with AssignStream() on Linux

Michael Van Canneyt michael.vancanneyt at wisa.be
Mon Jun 24 18:13:41 CEST 2002

On Sat, 22 Jun 2002, 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

> 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.

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

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.


More information about the fpc-pascal mailing list