On 06/16/2012 02:43 AM, Giuseppe Scrivano wrote: > Hi Micah, > > Micah Cowan <[email protected]> writes: > >> At first, I assumed wget was using errno improperly. Imagine my >> surprise, though, when running wget under a debugger, to find that at >> the tail end of main(), exit() gets called with an argument value of 0. >> But gdb then still reports a non-zero exit status - and this "wget: >> write error: No such file or directory" seems to get called _after_ wget >> calls exit. >> >> I finally figured out what's happening by setting a breakpoint at exit, >> and then setting one on write(), _after_ that first point hits. > > it smells like a regression in gnulib. I remember it was detecting > correctly EBADF before without report any error. Wget already closes > stdout in the "cleanup" function so when gnulib later attempts to do the > same thing. > > I am thinking about not using the close_stdout module but registering > "cleanup" at exit, I am going to investigate it.
The error message it's reporting seems to correspond to ENOENT instead... wonder if it's mistakenly getting that error from normal gettext() lookups, rather than any messages actually related to the close... the actual close(1) from the strace log in my first message, seems to have returned 0. If that's the case, shame on them! ;) errno shouldn't generally be considered meaningful unless it's set to 0 just prior to the call, and checked immediately after a verified-failed call. -mjc
