On 17/06/17 22:40, Nicholas Fitzkee wrote:
> Hi all,
> 
> I'm trying to use stdbuf on OpenWRT and I'm having some problems getting the
> correct behavior.  As I'm learning, cross-compiling is not easy, so I'm not
> sure if this is a bug or if I'm simply doing something wrong.  Probably the
> latter.
> 
> My application is rather convoluted, but I found a very nice test case on
> the openwrt website (https://github.com/openwrt/packages/issues/1674) .
> Running the following command buffers icmp entries when passed into awk:
> 
> tcpdump -eni eth0 -v icmp | awk '{print $1}'
> 
> If I ping an external website, the output of tcpdump is buffered so that awk
> prints several lines at a time.

Note stdbuf only controls stdio buffering.
I think tcpdump has other internal buffering for efficiency
so to disable that you probably have to pass the --immediate-mode
option to tcpdump?

> The following command should fix this:
> 
> stdbuf -oL tcpdump -eni eth0 -v icmp | awk '{print $1}'
> 
> On my router, I get the following error message:
> 
> root@DD-WRT:/opt/bin# stdbuf -oL tcpdump -eni eth0 icmp
> Error relocating /opt/bin/libstdbuf.so: __fprintf_chk: symbol not found

Blerg. Yes this looks like a cross compile issue.
Specifically it looks like you're cross compiling with the FORTIFY_SOURCE
in your CFLAGS, while support for that is not present in your libc.
Note we set CFLAGS for libstdbuf.so to: -fPIC $(AM_CFLAGS)
This is correct I think according to:
https://www.gnu.org/software/automake/manual/html_node/Flag-Variables-Ordering.html

So I'd look at getting these into the CFLAGS somehow when compiling the shared 
lib:

 -fno-stack-protector -D_FORTIFY_SOURCE=0

> root@DD-WRT:/opt/bin# stdbuf -oL date
> Sat Jun 17 23:45:49 CDT 2017

It's surprising that worked.

cheers,
Pádraig

Reply via email to