Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 6 Apr 2023 14:26:04 +0000
From:      Pete Wright <pete@nomadlogic.org>
To:        Pete <freebsd-questions-3@voidcaptain.com>
Cc:        Matthias Apitz <guru@unixarea.de>, Christian Weisgerber <naddy@mips.inka.de>, questions@freebsd.org
Subject:   Re: Clogged pipe?
Message-ID:  <20230406142604.dug4liknps2zuvvz@shelly.nomadlogic.org>
In-Reply-To: <4b563b2a-2c26-8c84-f8db-51e4f17dcaf6@slagle.net>
References:  <f8a7a545-9731-7481-4fb2-bfc77b8ad6f0@slagle.net> <ZCtavPuXQtYoV0TC@lorvorc.mips.inka.de> <d7565419-9dda-566c-5fc8-8815a43be3ca@slagle.net> <ZCu3TqNzhZBlDla7@pureos> <4b563b2a-2c26-8c84-f8db-51e4f17dcaf6@slagle.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Apr 04, 2023 at 12:25:36AM -0700, Pete wrote:
> Matthias Apitz wrote on 4/3/23 22:36:
> 
> Well, I was just showing a simplified example to illustrate the problem;
> what I was really trying to script is this:
> 
> /usr/bin/tail -f -n+1 /var/log/exim/main-$(/bin/date -u '+%Y%m%d').log |
> /bin/cat -n |
> /usr/bin/sed -Eu 's/^[[:blank:]]*([[:digit:]]*)[[:blank:]]+/\1 /'
> 
> which prefixes line numbers as it watches today's exim log file scroll
> along. So, in this case the -f flag is needed on the tail command.
> 
> What actually fixes the buffering problem on FreeBSD (it already works fine
> on Linux) is to add the -u flag to the cat command.
> 
> 

Jan Schaumann had a great blog post on pipes buffer sizes a while back
that may be interesting:
https://www.netmeister.org/blog/ipcbufs.html

It dives into the internals and does a pretty great break down of how
various OS's handle buffering.

-pete

-- 
Pete Wright
pete@nomadlogic.org



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20230406142604.dug4liknps2zuvvz>