This isn't amazingly serious, but it did surprise me.
I was using scandir() to browse a directory, and had implemented a
select() function to eliminate everything except regular files (by
calling stat() and then using S_ISREG). For test purposes, I put a
broken soft link in my scanned directory, and stat() correctly returned
an error. The odd part was that this caused scandir() to quit as well,
even though I had rejected this broken file from the selection.
Further study showed that returning from scandir() with errno set to
anything except 0 causes scandir() to fail immediately.
This strikes me as odd - is it intentional? I can't find any
documentation about it.