Ensure that the fix for #17269 also works on OSX 10.4

AI_NUMERICSERV isn't defined on OSX 10.4.
Issue #18174: Fix fd leaks in tests.