wpa_supplicant: garbled log

Denys Vlasenko vda.linux at googlemail.com
Fri Sep 27 21:51:45 EDT 2013


Hi,

I'm running wpa_supplicant in a way where both
its stdout and stderr go to the same file descriptor,
which isn't a tty. IOW, I do this:

wpa_supplicant ... -dd 2&>1 | a_logger_tool

The log looks mostly ok, but sometimes I see stuff like this:

...
Add randomnes: count=ioctl[SIOCSIWFREQ]: Device or resource busy
3 entropy=2
...

Clearly, it was a perror("ioctl[SIOCSIWFREQ]"), and stdout
buffer happened to be not on a line boundary when perror()
sent its message to stderr.

This would not be noticed if stdout and stderr are separate,
or if they print to a tty, since in this case they are initialized
to line buffered mode.

One possible fix is to call  setlinebuf(stdout)  somewhere early
in main(); another is to fflush(stdout) or fflush(NULL) before
every perror().

Since wpa_supplicant doesn't print megabytes of log per second
and shouldn't worry about high efficiency of writing its stdout
I think using  setlinebuf(stdout)  is quite ok.

-- 
vda



More information about the HostAP mailing list