lua-users home
lua-l archive

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


Ok, so the behaviour for closing stdin/stdout/stderr changed.
Formerly it was allowed:

  $ lua512 -e 'print(io.close(io.stderr))'
  true

With Lua 5.1.3 it's no longer allowed. That's fine. But returning
a random error message is not so nice:

  $ lua513-rc1 -e 'print(io.close(io.stderr))'
  nil	Success	0

  $ lua513-rc1 -e 'io.open(""); print(io.close(io.stderr))'
  nil	No such file or directory	2

Yes, this is a reappearing bug from Lua 5.0 and Lua 5.1-work6. I
strongly suggest to add a test case for this. ;-)

Oh, and I recommend to replace the comparison of FILE objects
against stdin/stdout/stderr with a noclose flag which is set upon
creation of the Lua objects for these file handles. Otherwise one
cannot close a file object which happens to use descriptor 0, 1
or 2. A patch for both issues is in the mailing list archive.

--Mike