clinuxsystem-callsposix-select

select()-able timers


select() is a great system call. You can pack any number of file descriptors, socket descriptors, pipes, etc. and get notified in a synchronous fashion when input becomes available.

Is there a way to create an interval/oneshot timer and use it with select()? That would save me from having multiple threads for IO and timing.


Solution

  • timerfd_create does exactly this. It's a fairly recent addition to the linux kernel and might not be available on all distros yet though.