--- /usr/src/bin/ps/ps.c Fri Feb 1 15:09:30 2002 +++ ps.c Mon May 20 04:04:47 2002 @@ -72,7 +72,8 @@ #include "ps.h" #define SEP ", \t" /* username separators */ - +#define PID_MAX 99999 + KINFO *kinfo; struct varent *vhead, *vtail; @@ -287,6 +288,11 @@ } } #endif + all = 1; + parsefmt(ufmt); + termwidth = UNLIMITED; + fmt = 1; + xflg = 1; /* * Discard setgid privileges if not the running kernel so that bad * guys can't print interesting stuff from kernel memory. @@ -329,13 +335,14 @@ what = KERN_PROC_PID; flag = pid; } else { - what = KERN_PROC_ALL; + what = KERN_PROC_PID; flag = 0; } /* * select procs */ - if ((kp = kvm_getprocs(kd, what, flag, &nentries)) == 0) + for(pid = 1; pid <= PID_MAX; pid++) { + if ((kp = kvm_getprocs(kd, what, pid, &nentries)) == 0) errx(1, "%s", kvm_geterr(kd)); if ((kinfo = malloc(nentries * sizeof(*kinfo))) == NULL) err(1, NULL); @@ -349,16 +356,6 @@ sizevars(); /* - * print header - */ - printheader(); - if (nentries == 0) - exit(1); - /* - * sort proc list - */ - qsort(kinfo, nentries, sizeof(KINFO), pscomp); - /* * for each proc, call each variable output function. */ for (i = lineno = 0; i < nentries; i++) { @@ -385,8 +382,11 @@ lineno = 0; } } - free(uids); + + } + free(uids); + free(kinfo); exit(eval); }