Small patch to fix top in large NIS environments

Gavin Atkinson gavin.atkinson at
Wed Jan 9 11:06:20 PST 2008

On Wed, 2008-01-09 at 12:15 -0500, David Frascone wrote:
> The -u flag to top is supposed to limit uid lookups.  But, it was still
> spinning through the entire password database with while (getpwent()).  At
> Cisco, which has a fairly large NIS database, this takes forever, and top
> never starts.
> I filed this bug to address it:
> The attached patch fixes it.  This is my first submission, so let me know if
> this is the proper order, etc, to post the patches (i.e. file the bug, the
> post a fix)

This is a longstanding bug, sadly.  bin/20799 seems to be the first to
mention it, and is over 7 years old now.  Every system I deploy at work
has to have top(1) patched to avoid this.

I think your solution of not sizing the usernames when -u is specified
is a sensible one, although I think some thought really needs to be put
into whether sizing is necessary at all - maybe the solution is to just
limit the username field to 8 or 10 characters or so, and either trim
longer names or show them as userids.  Parsing a huge (in my case
~25,000 users) password map when top is run seems stupid, especially
given that many invocations of top are at exactly the time when
significant extra load on a system is not a good idea.

It would probably be best to submit your patch as a followup to PR


More information about the freebsd-current mailing list