[fpc-pascal] BlockWrite() version 2.6.4

Karoly Balogh (Charlie/SGR) charlie at scenergy.dfmk.hu
Mon Aug 14 16:46:31 CEST 2017


Hi,

On Mon, 14 Aug 2017, Brian wrote:

> Thanks Charlie.
>
> I notice the Do_Write() uses  repeat .. until where fpWrite() does a direct
> call.
>
> What was the reasoning for the repeat..until in Do_Write() ?

Because FpWrite() is just the direct Unix OS call, so the RTL doesn't add
extra behavior there. While Do_Write() which integrates this OS call into
the FPC RTL has to do some error handling. In this case, if the system
reports EAGAIN or EINTR errors, the write call will be attempted again,
without returning an error to the program calling BlockWrite().

There are several reasons why an Unix write() might return EAGAIN or
EINTR. These are documented in the Unix manpage for write:

https://linux.die.net/man/2/write

The RTL just tries to handle these recoverable error cases in the
Do_Write() function, until the write() fails irrecoverably or it succeeds.
Hence the repeat...until.

Charlie




More information about the fpc-pascal mailing list