1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-20 15:43:16 +00:00

Fix breakage after moving from struct proc/eproc to kinfo_proc.

This commit is contained in:
Andrzej Bialecki 2001-01-10 22:24:07 +00:00
parent 891b3d045f
commit 650da9d30a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=70906

View File

@ -36,7 +36,6 @@
#include <sys/param.h>
#include <sys/sysctl.h>
#include <sys/stat.h>
#include <sys/proc.h>
#include <sys/user.h>
char p_stat[]="?iRSTZWM";
@ -45,10 +44,8 @@ int
main(int argc, char *argv[])
{
int mib[4],i=0, num, len, j, plen;
int sz = sizeof(struct proc) + sizeof(struct eproc);
struct proc *p;
struct eproc *ep;
char buf[MAXPATHLEN],vty[5],pst[5], wmesg[10];
struct kinfo_proc *ki;
char *t;
int ma,mi;
@ -65,32 +62,31 @@ main(int argc, char *argv[])
exit(1);
}
mib[2]=KERN_PROC_ARGS;
num = len / sz;
num = len / KINFO_PROC_SIZE;
i=0;
printf("USERNAME PID PPID PRI NICE TTY STAT WCHAN COMMAND\n");
while(i < num) {
p=(struct proc *)(t + (num - i - 1) * sz);
ep=(struct eproc *)(t + (num - i - 1) * sz + sizeof(struct proc));
mib[3]=p->p_pid;
ki = (struct kinfo_proc *)(t + (num - i - 1) * KINFO_PROC_SIZE);
mib[3] = ki->ki_pid;
plen = MAXPATHLEN;
if(sysctl(mib,4,buf,&plen,NULL,0)) {
perror("sysctl info");
exit(1);
}
if(plen == 0) {
sprintf(buf, "(%s)", p->p_comm);
sprintf(buf, "(%s)", ki->ki_comm);
} else {
for(j=0; j < plen-1; j++) {
if(buf[j] == '\0') buf[j] = ' ';
}
}
if(strcmp(ep->e_wmesg, "") == 0) {
if(strcmp(ki->ki_wmesg, "") == 0) {
sprintf(wmesg, "-");
} else {
strcpy(wmesg, ep->e_wmesg);
strcpy(wmesg, ki->ki_wmesg);
}
ma=major(ep->e_tdev);
mi=minor(ep->e_tdev);
ma=major(ki->ki_tdev);
mi=minor(ki->ki_tdev);
switch(ma) {
case 255:
strcpy(vty,"??");
@ -108,13 +104,13 @@ main(int argc, char *argv[])
sprintf(vty,"p%d",mi);
break;
}
sprintf(pst,"%c",p_stat[p->p_stat]);
sprintf(pst,"%c",p_stat[ki->ki_stat]);
printf("%8s %5u %5u %3d %4d %3s %-4s %-7s %s\n",
ep->e_login,
p->p_pid,
ep->e_ppid,
p->p_priority - 22,
p->p_nice,
ki->ki_login,
ki->ki_pid,
ki->ki_ppid,
ki->ki_priority - 22,
ki->ki_nice,
vty,
pst,
wmesg,