[fpc-pascal] Writing to a drive which may be spun down

Brian b_lists at patandbrian.org
Thu Nov 21 07:16:16 CET 2019

Hi all,

Running Ubuntu 18 LTS, I have a console-mode number-cruncher which
writes occasional output files. It works just fine if the output is
directed to a drive which is permanently spun up, but can fail if the
output is directed to a USB drive (by which I mean a USB-connected 8TB
external drive, not one of the keydrives). I've followed things
through with the debugger, and it seems that the problem occurs when
the drive has powered itself down due to lack of accesses. The assign
and rewrite work OK, but then the first attempt to write to the file
fails with a 'No such file' error. Putting a large (30 second!) delay
before the first write means everything works OK, presumably because
the drive gets time to spin up again.

My question: Is there a standard method for handling this situation,
i.e. making sure that a drive has not spun down, or is it just a case
of writing a wrapper round the write function and handling the 'No
such file' error with a wait and a retry?



More information about the fpc-pascal mailing list