Mark
Mark

Reputation: 6474

is select() blocking or non-blocking call

Is it fair to say that select() is non-blocking when it passes struct timeval argument with timeout value? And when that argument is NULL, it is blocking.

Upvotes: 3

Views: 1889

Answers (1)

Steffen Ullrich
Steffen Ullrich

Reputation: 123320

Is is fair to say that select() is non-blocking when it passes struct timeval argument with timeout value?

No. It is waiting in this case until either one of the selected file descriptors get ready or the timeout is reached. This "waiting" is clearly blocking.

The only case where this is non-blocking is if the timeout is 0, i.e. tv_sec and tv_usec of the given timeval are set to 0.

Upvotes: 9

Related Questions