Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 11 Dec 2006 11:23:55 -0600
From:      Dan Nelson <dnelson@allantgroup.com>
To:        c0re dumped <ez.c0re@gmail.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Reading in real time from a file without pipes
Message-ID:  <20061211172354.GE69299@dan.emsphone.com>
In-Reply-To: <6dd8736a0612110908q2cdb99a0rf3b8da3f5e4bdfee@mail.gmail.com>
References:  <6dd8736a0612110908q2cdb99a0rf3b8da3f5e4bdfee@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
In the last episode (Dec 11), c0re dumped said:
> I wonder if is possible to read data from a certain file without
> using a pipe.
> 
> Let me explain:
> 
> I have a process already writing messages to a logfile. I want to
> read all written data (without neither stop nor interfere normal log
> process) from another process in real time.
> 
> How can I achieve it ?

Take a look at how the tail command does it.  You can either stat the
file periodically then read the new data if you see the timestamp or
size change (portable), or use a kqueue to get notified immediately of
any updates (not portable).

-- 
	Dan Nelson
	dnelson@allantgroup.com



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