in reply to Stefan Eissing

I think it's reasonable to declare that pthread_cancel() is effectively broken for any nontrivial use on contemporary OSes and it is unlikely to be fixed any time soon.

(I suspect it would actually be easier to cajole libc maintainers into adding an async friendly version of GAI() than to make GAI() cancellation safe.)

If you want a cancellable thing from which you can make blocking calls, the only near-universal option is subprocesses. Unfortunately there are reasons why in some ecosystems it is impolite for a library to start a subprocess.