Re: select() bug

Richard B. Johnson
2000-11-03T13:06:09Z

On Fri, 3 Nov 2000, Paul Marquis wrote:

> It shows that even though select() says a file descriptor is not
> writable, a write() can still succeed. This code is not used anywhere
> in the real world, or at least my real world :-P. It just demonstrates
> "the bug".
>

It demonstrates nothing except bad code. Anybody should know that
such a descriptor can become writable at any instant, simply because
the kernel may be finding room for more unread data.

So, the code sees that, at this instant, it's not writable. Then
it writes to it anyway. Sometimes the fd becomes writable between
the time that it was checked, and the time it was written. So
the write succeeded. So what. It shows nothing but bad code. It
demonstrates no bug whatsover.

There may be a bug. However, this code doesn't demonstrate anything
but bad coding practice.

Cheers,
Dick Johnson

Penguin : Linux version 2.2.17 on an i686 machine (801.18 BogoMips).

"Memory is like gasoline. You use it up when you are running. Of
course you get it all back when you reboot..."; Actual explanation
obtained from the Micro$oft help desk.