lua-users home
lua-l archive

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


On Tue, Nov 8, 2011 at 9:48 AM, 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.)

batrick@neverwinter:~$ lua
Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
> f = io.open("/proc/self/mem")
> =f
file (0x144f760)
> =f:read()
nil	Input/output error	5


Usually first memory block is not mapped so this will always result in an error.

-- 
- Patrick Donnelly