lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


One ugly way is to close the file descriptor behind the standard C
library's back. You could add a routine to your test harness that in
effect performs

  close(fileno(file));

It's ugly but it works. Other ugly things I can think off: mount a
thumb drive, and yank it out after opening a large file, it must be
large so it does not get completely loaded into buffer cache on open..
Make sure you do not have anything essential on that drive, unless you
mount it read-only :-)

There are other ways but they require kernel hacks.

Gé



-- Gé

On Nov 8, 2011, at 6:48, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:

> I am trying to test errors in read operations (io.read - io.line). Does
> anyone know a reliable/automatic way to generate a read error on
> Linux? (That is, a situation where fread returns EOF and ferror returns
> not zero.)
>
> -- Roberto
>