wpa_supplicant: garbled log
j at w1.fi
Sat Sep 28 05:37:49 EDT 2013
On Sat, Sep 28, 2013 at 03:51:45AM +0200, Denys Vlasenko wrote:
> 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:
> 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.
stderr should not really be used, i.e., all the perror() calls should
really be replace with something like wpa_printf(MSG_ERROR, "msg..: %s",
> 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.
This is not really desirable for number of P2P operations that do depend
on timing quite a bit. Getting rid of perror() (and other users of
stderr, if any) would be better approach.
Jouni Malinen PGP id EFC895FA
More information about the HostAP