You should really explain what that race condition is.
alarm(1);
// alarm could theoretically be triggered here before read() syscall is executed
read(...);
This sort of problem is what the self pipe trick https://cr.yp.to/docs/selfpipe.html is made to solve. I believe it is not really necessary anymore because there are functions like pselect() which solve this by accepting a sigmask parameter.Anyway, most system calls that one would want to have a timeout for have alternatives that accept a timeout parameter.