H. S. Teoh writes ("Bug#12411: [PATCH] A better Directory Lister example"):
...
> I have declined to address this, since this example is mainly concerned
> with using the libc directory reading functions, not with handling stdout
> errors.I actually think it's a libc bug, #28250. > > * it prints the error message about failing to open the directory to > > stdout instead of stderr; > > The current version of the info file uses perror(), which, as far as I > know, print to stderr, not stdout. I think some of the things I reported must have been fixed in the meantime. Thanks, Ian.

