Small patch to fix top in large NIS environments

David Frascone dave at
Wed Jan 9 09:43:28 PST 2008

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)

-------------- next part --------------
Index: usr.bin/top/machine.c
RCS file: /usr/FreeBSD/cvsup/src/usr.bin/top/machine.c,v
retrieving revision 1.83
diff -r1.83 machine.c
< machine_init(struct statics *statics)
> machine_init(struct statics *statics, char do_unames)
< 	while ((pw = getpwent()) != NULL) {
> 	if (do_unames) {
> 	    while ((pw = getpwent()) != NULL) {
> 	    }
Index: contrib/top/top.c
RCS file: /usr/FreeBSD/cvsup/src/contrib/top/top.c,v
retrieving revision 1.23
diff -r1.23 top.c
<     if (machine_init(&statics) == -1)
>     if (machine_init(&statics, do_unames) == -1)

More information about the freebsd-current mailing list