mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-16 10:20:30 +00:00
Fill in the some new fields 'struct kinfo_proc', namely ki_childstime,
ki_childutime, and ki_emul. Also uses the timevaladd() routine to correct the calculation of ki_childtime. That will correct the value returned when ki_childtime.tv_usec > 1,000,000. This also implements a new KERN_PROC_GID option for kvm_getprocs(). (there will be a similar update to lib/libkvm/kvm_proc.c) Submitted by: Cyrille Lefevre
This commit is contained in:
parent
d688cb4c0d
commit
078842c5c9
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=130727
@ -694,10 +694,11 @@ fill_kinfo_thread(struct thread *td, struct kinfo_proc *kp)
|
||||
kp->ki_start = p->p_stats->p_start;
|
||||
timevaladd(&kp->ki_start, &boottime);
|
||||
kp->ki_rusage = p->p_stats->p_ru;
|
||||
kp->ki_childtime.tv_sec = p->p_stats->p_cru.ru_utime.tv_sec +
|
||||
p->p_stats->p_cru.ru_stime.tv_sec;
|
||||
kp->ki_childtime.tv_usec = p->p_stats->p_cru.ru_utime.tv_usec +
|
||||
p->p_stats->p_cru.ru_stime.tv_usec;
|
||||
kp->ki_childstime = p->p_stats->p_cru.ru_stime;
|
||||
kp->ki_childutime = p->p_stats->p_cru.ru_utime;
|
||||
/* Some callers want child-times in a single value */
|
||||
kp->ki_childtime = kp->ki_childstime;
|
||||
timevaladd(&kp->ki_childtime, &kp->ki_childutime);
|
||||
}
|
||||
if (p->p_state != PRS_ZOMBIE) {
|
||||
#if 0
|
||||
@ -805,6 +806,9 @@ fill_kinfo_thread(struct thread *td, struct kinfo_proc *kp)
|
||||
strlcpy(kp->ki_comm, p->p_comm, sizeof(kp->ki_comm));
|
||||
strlcpy(kp->ki_ocomm, p->p_comm, sizeof(kp->ki_ocomm));
|
||||
}
|
||||
if (p->p_sysent && p->p_sysent->sv_name != NULL &&
|
||||
p->p_sysent->sv_name[0] != '\0')
|
||||
strlcpy(kp->ki_emul, p->p_sysent->sv_name, sizeof(kp->ki_emul));
|
||||
kp->ki_siglist = p->p_siglist;
|
||||
SIGSETOR(kp->ki_siglist, td->td_siglist);
|
||||
kp->ki_sigmask = td->td_sigmask;
|
||||
@ -978,6 +982,14 @@ sysctl_kern_proc(SYSCTL_HANDLER_ARGS)
|
||||
*/
|
||||
switch (oid_number) {
|
||||
|
||||
case KERN_PROC_GID:
|
||||
if (p->p_ucred == NULL ||
|
||||
p->p_ucred->cr_gid != (gid_t)name[0]) {
|
||||
PROC_UNLOCK(p);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
|
||||
case KERN_PROC_PGRP:
|
||||
/* could do this by traversing pgrp */
|
||||
if (p->p_pgrp == NULL ||
|
||||
@ -1187,6 +1199,9 @@ SYSCTL_NODE(_kern, KERN_PROC, proc, CTLFLAG_RD, 0, "Process table");
|
||||
SYSCTL_PROC(_kern_proc, KERN_PROC_ALL, all, CTLFLAG_RD|CTLTYPE_STRUCT,
|
||||
0, 0, sysctl_kern_proc, "S,proc", "Return entire process table");
|
||||
|
||||
SYSCTL_NODE(_kern_proc, KERN_PROC_GID, gid, CTLFLAG_RD,
|
||||
sysctl_kern_proc, "Process table");
|
||||
|
||||
SYSCTL_NODE(_kern_proc, KERN_PROC_PGRP, pgrp, CTLFLAG_RD,
|
||||
sysctl_kern_proc, "Process table");
|
||||
|
||||
@ -1217,6 +1232,9 @@ SYSCTL_NODE(_kern_proc, KERN_PROC_ARGS, args, CTLFLAG_RW | CTLFLAG_ANYBODY,
|
||||
SYSCTL_NODE(_kern_proc, KERN_PROC_SV_NAME, sv_name, CTLFLAG_RD,
|
||||
sysctl_kern_proc_sv_name, "Process syscall vector name (ABI type)");
|
||||
|
||||
SYSCTL_NODE(_kern_proc, (KERN_PROC_GID | KERN_PROC_INC_THREAD), gid_td,
|
||||
CTLFLAG_RD, sysctl_kern_proc, "Process table");
|
||||
|
||||
SYSCTL_NODE(_kern_proc, (KERN_PROC_PGRP | KERN_PROC_INC_THREAD), pgrp_td,
|
||||
CTLFLAG_RD, sysctl_kern_proc, "Process table");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user