Solving bug when opening a Lua file descriptor