Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You should really explain what that race condition is.


I think they are referring to the fact that the signal could be triggered before the system call is executed, in which case you will miss the signal and the system call will never time out. For example:

  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.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: