Fix luv_backend_fd returning "Unknown system error" on Windows
uv_backend_fd returns a bare -1 (not an error code) on Windows, so interpreting it as an error code is wrong. backend_fd now returns nil when no backend fd exists
@@ -51,7 +51,10 @@ static int luv_stop(lua_State* L) {
static int luv_backend_fd(lua_State* L) {
int ret = uv_backend_fd(luv_loop(L));
- if (ret < 0) return luv_error(L, ret);
+ // -1 is returned when there is no backend fd (like on Windows)
+ if (ret == -1)
+ lua_pushnil(L);
+ else
lua_pushinteger(L, ret);
return 1;
}
