In _this_ particular case, you could just tell curl to internally timeout the request (via `-m`) instead of trying to manage the timeout on the process level
there are multiple docs with nice explanations too, for example:
https://everything.curl.dev/usingcurl/downloads/retry.html
i guess the premise is applicable to other processes which do not implement timeouts (eg: find) themselves