luaposix has a function fileno(file) wich does this.
Thanks for the pointer. Nevertheless, pull luaposix as dependence in only to use a hack over luasocket looks weird... Why not use luaposix's select() then?
What about using Alien [1] to declare a binding to that function? (fileno) It is one more dependency, yes, but it might be lighter than luaposix (don't know, really).