Subject: Re: tail(1) seg faults on i/o error, with fix
To: Dieter <>
From: Chuck Silvers <>
List: netbsd-bugs
Date: 02/16/2005 09:51:48

it would be much better to catch the signal and fail gracefully that way,
rather than incur all the overhead of mlock().


On Wed, Feb 16, 2005 at 09:29:04AM +0000, Dieter wrote:
> The tail(1) utility gets a segmentation fault core dump
> if it gets an i/o error.  This happens on 1.6.2 and 2.0
> (and probably other releases as well).
> Repeat by: run tail on a file that gives an i/o error.
> The problem is using mmap(2) and not insuring that the
> data can be read.  I fixed it with mlock(2), which
> allows a graceful handling of the i/o error without
> a core dump.
> The diff below (against 2.0) fixes the problem.  I make
> no claim that this is the best fix, or the most efficient fix.
> (It does an mlock() and munlock for each char.)
> It probably isn't necessary to exit upon i/o error.
> There are probably other programs lurking out there
> using mmap unsafely.  :-(