From: Ben Gras Date: Mon, 28 Jun 2010 11:05:34 +0000 (+0000) Subject: make ps and top use sanity checking kernel proc table retrieval X-Git-Tag: v3.1.8~320 X-Git-Url: http://zhaoyanbai.com/repos/doc/roff.7.html?a=commitdiff_plain;h=f044bd10efbd877d01b3be29bdadee4f0e2ad12d;p=minix.git make ps and top use sanity checking kernel proc table retrieval --- diff --git a/commands/ps/ps.c b/commands/ps/ps.c index 72b397a48..3be292482 100644 --- a/commands/ps/ps.c +++ b/commands/ps/ps.c @@ -344,8 +344,8 @@ char *argv[]; if (ps_proc == NULL || ps_mproc == NULL || ps_fproc == NULL) err("Out of memory"); - if(getsysinfo(PM_PROC_NR, SI_KPROC_TAB, ps_proc) < 0) { - fprintf(stderr, "getsysinfo() for SI_KPROC_TAB failed.\n"); + if(minix_getkproctab(ps_proc, nr_tasks + nr_procs, 1) < 0) { + fprintf(stderr, "minix_getkproctab failed.\n"); exit(1); } diff --git a/commands/top/top.c b/commands/top/top.c index f63d3bf68..fa19dc665 100644 --- a/commands/top/top.c +++ b/commands/top/top.c @@ -358,10 +358,11 @@ void showtop(int r) #endif retry: - if(getsysinfo(PM_PROC_NR, SI_KPROC_TAB, proc) < 0) { - fprintf(stderr, "getsysinfo() for SI_KPROC_TAB failed.\n"); + if(minix_getkproctab(proc, PROCS, 1) < 0) { + fprintf(stderr, "minix_getkproctab failed.\n"); exit(1); } + if (!preheated) { preheated = 1; memcpy(prev_proc, proc, sizeof(prev_proc));