This is not a good use of EINTR, you can even see it’s fundamentally flawed given this usage introduces a race condition.
pselect() isn’t the right answer given it’s not portable and it’s totally broken on various versions of macOS. signalfd() is also not the answer, it suffers from a broken design: https://ldpreload.com/blog/signalfd-is-useless
To deal with cleanup on a signal while blocking in a robust and portable way, use the self pipe trick and select() (or equivalent).
pselect() isn’t the right answer given it’s not portable and it’s totally broken on various versions of macOS. signalfd() is also not the answer, it suffers from a broken design: https://ldpreload.com/blog/signalfd-is-useless
To deal with cleanup on a signal while blocking in a robust and portable way, use the self pipe trick and select() (or equivalent).