bitcoin-cli -rpcclienttimeout=0 is documented as "no timeout", but on macOS it fails with "Could not connect to the server" since #34342 (it's in v32.0rc1/rc2).
bitcoin-cli turns 0 into std::chrono::years(5) and passes it to Sock::Wait. On platforms without USE_POLL (everything except Linux) WaitMany uses select(), and macOS returns EINVAL for timeouts above 10^8 seconds. Five years is about 1.58 * 10^8 s. The same happens with any explicit value above 10^8, e.g. -rpcclienttimeout=110000000. On Linux, poll() takes the timeout as an int, so the millisecond count gets narrowed. For five years this happens to wrap to a negative value, which means infinite, so it works there by accident.
This caps the timeout in Sock::WaitMany at INT_MAX milliseconds (about 24.8 days). That fits poll() and is below the 31 days POSIX requires select() to support. Doing it in WaitMany covers every caller, not only bitcoin-cli.
The new sock_tests/wait_large_timeout test waits with a 5 year timeout on a socket that already has data. It fails on master on macOS and passes with this change. I also checked by hand on macOS that -rpcclienttimeout=0, 157784760 and 2147483647 work against a running node, and interface_bitcoin_cli.py still passes.
This doesn't overlap with #36299, which changes how the timeout is counted but still passes the 5 year value down.