From: Ben Gras Date: Wed, 29 Mar 2006 12:44:06 +0000 (+0000) Subject: 1-sized passwd cache X-Git-Tag: v3.1.2a~104 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/man.host.html?a=commitdiff_plain;h=cdcb3df82113dbd11ddc18bbbc6a59007dd72e97;p=minix.git 1-sized passwd cache --- diff --git a/commands/simple/top.c b/commands/simple/top.c index d2d1eeab9..826dcfe00 100644 --- a/commands/simple/top.c +++ b/commands/simple/top.c @@ -158,10 +158,11 @@ void print_procs(int maxlines, maxlines--; for(p = 0; p < nprocs; p++) { int euid = 0; - struct passwd *who = NULL; struct proc *pr; int pnr, ticks; char *name = ""; + static struct passwd *who = NULL; + static int last_who = -1; if(maxlines-- <= 0) break; @@ -176,7 +177,10 @@ void print_procs(int maxlines, printf("[%3d] ", pnr); name = pr->p_name; } - who = getpwuid(euid); + if(last_who != euid || !who) { + who = getpwuid(euid); + last_who = euid; + } if(who && who->pw_name) printf("%-8s ", who->pw_name); else if(pnr >= 0) printf("%8d ", mproc[pnr].mp_effuid);