Lines Matching +full:1 +full:k

10  * 1. Redistributions of source code must retain the above copyright
94 arguments(KINFO *k, VARENT *ve) in arguments() argument
98 if ((vis_args = malloc(strlen(k->ki_args) * 4 + 1)) == NULL) in arguments()
99 xo_errx(1, "malloc failed"); in arguments()
100 strvis(vis_args, k->ki_args, VIS_TAB | VIS_NL | VIS_NOSLASH); in arguments()
109 command(KINFO *k, VARENT *ve) in command() argument
117 k->ki_d.prefix ? k->ki_d.prefix : "", in command()
118 k->ki_p->ki_comm, in command()
119 (showthreads && k->ki_p->ki_numthreads > 1) ? "/" : "", in command()
120 (showthreads && k->ki_p->ki_numthreads > 1) ? k->ki_p->ki_tdname : "", in command()
121 (showthreads && k->ki_p->ki_numthreads > 1) ? k->ki_p->ki_moretdname : ""); in command()
123 str = strdup(k->ki_p->ki_comm); in command()
127 if ((vis_args = malloc(strlen(k->ki_args) * 4 + 1)) == NULL) in command()
128 xo_errx(1, "malloc failed"); in command()
129 strvis(vis_args, k->ki_args, VIS_TAB | VIS_NL | VIS_NOSLASH); in command()
134 if (k->ki_env) { in command()
135 if ((vis_env = malloc(strlen(k->ki_env) * 4 + 1)) in command()
137 xo_errx(1, "malloc failed"); in command()
138 strvis(vis_env, k->ki_env, in command()
144 k->ki_d.prefix ? k->ki_d.prefix : "", in command()
164 ucomm(KINFO *k, VARENT *ve) in ucomm() argument
170 k->ki_d.prefix ? k->ki_d.prefix : "", in ucomm()
171 k->ki_p->ki_comm, in ucomm()
172 (showthreads && k->ki_p->ki_numthreads > 1) ? "/" : "", in ucomm()
173 (showthreads && k->ki_p->ki_numthreads > 1) ? k->ki_p->ki_tdname : "", in ucomm()
174 (showthreads && k->ki_p->ki_numthreads > 1) ? k->ki_p->ki_moretdname : ""); in ucomm()
176 if (showthreads && k->ki_p->ki_numthreads > 1) in ucomm()
177 asprintf(&str, "%s/%s%s", k->ki_p->ki_comm, in ucomm()
178 k->ki_p->ki_tdname, k->ki_p->ki_moretdname); in ucomm()
180 str = strdup(k->ki_p->ki_comm); in ucomm()
186 tdnam(KINFO *k, VARENT *ve __unused) in tdnam() argument
190 if (showthreads && k->ki_p->ki_numthreads > 1) in tdnam()
191 asprintf(&str, "%s%s", k->ki_p->ki_tdname, in tdnam()
192 k->ki_p->ki_moretdname); in tdnam()
200 logname(KINFO *k, VARENT *ve __unused) in logname() argument
203 if (*k->ki_p->ki_login == '\0') in logname()
205 return (strdup(k->ki_p->ki_login)); in logname()
209 state(KINFO *k, VARENT *ve __unused) in state() argument
216 xo_errx(1, "malloc failed"); in state()
218 flag = k->ki_p->ki_flag; in state()
219 tdflags = k->ki_p->ki_tdflags; /* XXXKSE */ in state()
222 switch (k->ki_p->ki_stat) { in state()
230 *cp = k->ki_p->ki_slptime >= MAXSLP ? 'I' : 'S'; in state()
256 if (k->ki_p->ki_nice < NZERO || k->ki_p->ki_pri.pri_class == PRI_REALTIME) in state()
258 else if (k->ki_p->ki_nice > NZERO || k->ki_p->ki_pri.pri_class == PRI_IDLE) in state()
262 if (flag & P_WEXIT && k->ki_p->ki_stat != SZOMB) in state()
266 if ((flag & P_SYSTEM) || k->ki_p->ki_lock > 0) in state()
268 if ((k->ki_p->ki_cr_flags & KI_CRF_CAPABILITY_MODE) != 0) in state()
270 if (k->ki_p->ki_kiflag & KI_SLEADER) in state()
272 if ((flag & P_CONTROLT) && k->ki_p->ki_pgid == k->ki_p->ki_tpgid) in state()
283 pri(KINFO *k, VARENT *ve __unused) in pri() argument
287 asprintf(&str, "%d", scalepri(k->ki_p->ki_pri.pri_level)); in pri()
292 upr(KINFO *k, VARENT *ve __unused) in upr() argument
296 asprintf(&str, "%d", scalepri(k->ki_p->ki_pri.pri_user)); in upr()
302 username(KINFO *k, VARENT *ve __unused) in username() argument
305 return (strdup(user_from_uid(k->ki_p->ki_uid, 0))); in username()
309 egroupname(KINFO *k, VARENT *ve __unused) in egroupname() argument
312 return (strdup(group_from_gid(k->ki_p->ki_groups[0], 0))); in egroupname()
316 rgroupname(KINFO *k, VARENT *ve __unused) in rgroupname() argument
319 return (strdup(group_from_gid(k->ki_p->ki_rgid, 0))); in rgroupname()
323 runame(KINFO *k, VARENT *ve __unused) in runame() argument
326 return (strdup(user_from_uid(k->ki_p->ki_ruid, 0))); in runame()
330 tdev(KINFO *k, VARENT *ve __unused) in tdev() argument
335 dev = k->ki_p->ki_tdev; in tdev()
345 tname(KINFO *k, VARENT *ve __unused) in tname() argument
350 dev = k->ki_p->ki_tdev; in tname()
360 k->ki_p->ki_kiflag & KI_CTTY ? ' ' : '-'); in tname()
367 longtname(KINFO *k, VARENT *ve __unused) in longtname() argument
372 dev = k->ki_p->ki_tdev; in longtname()
380 started(KINFO *k, VARENT *ve __unused) in started() argument
387 if (!k->ki_valid) in started()
392 xo_errx(1, "malloc failed"); in started()
394 then = k->ki_p->ki_start.tv_sec; in started()
396 if (now - k->ki_p->ki_start.tv_sec < 24 * 3600) { in started()
398 } else if (now - k->ki_p->ki_start.tv_sec < 7 * 86400) { in started()
406 lstarted(KINFO *k, VARENT *ve __unused) in lstarted() argument
412 if (!k->ki_valid) in lstarted()
417 xo_errx(1, "malloc failed"); in lstarted()
419 then = k->ki_p->ki_start.tv_sec; in lstarted()
425 lockname(KINFO *k, VARENT *ve __unused) in lockname() argument
429 if (k->ki_p->ki_kiflag & KI_LOCKBLOCK) { in lockname()
430 if (k->ki_p->ki_lockname[0] != 0) in lockname()
431 str = strdup(k->ki_p->ki_lockname); in lockname()
441 wchan(KINFO *k, VARENT *ve __unused) in wchan() argument
445 if (k->ki_p->ki_wchan) { in wchan()
446 if (k->ki_p->ki_wmesg[0] != 0) in wchan()
447 str = strdup(k->ki_p->ki_wmesg); in wchan()
449 asprintf(&str, "%lx", (long)k->ki_p->ki_wchan); in wchan()
457 nwchan(KINFO *k, VARENT *ve __unused) in nwchan() argument
461 if (k->ki_p->ki_wchan) in nwchan()
462 asprintf(&str, "%0lx", (long)k->ki_p->ki_wchan); in nwchan()
470 mwchan(KINFO *k, VARENT *ve __unused) in mwchan() argument
474 if (k->ki_p->ki_wchan) { in mwchan()
475 if (k->ki_p->ki_wmesg[0] != 0) in mwchan()
476 str = strdup(k->ki_p->ki_wmesg); in mwchan()
478 asprintf(&str, "%lx", (long)k->ki_p->ki_wchan); in mwchan()
479 } else if (k->ki_p->ki_kiflag & KI_LOCKBLOCK) { in mwchan()
480 if (k->ki_p->ki_lockname[0]) { in mwchan()
481 str = strdup(k->ki_p->ki_lockname); in mwchan()
491 vsize(KINFO *k, VARENT *ve __unused) in vsize() argument
495 asprintf(&str, "%lu", (u_long)(k->ki_p->ki_size / 1024)); in vsize()
500 printtime(KINFO *k, VARENT *ve __unused, long secs, long psecs) in printtime() argument
508 if (!k->ki_valid) { in printtime()
523 cputime(KINFO *k, VARENT *ve) in cputime() argument
532 secs = k->ki_p->ki_runtime / 1000000; in cputime()
533 psecs = k->ki_p->ki_runtime % 1000000; in cputime()
535 secs += k->ki_p->ki_childtime.tv_sec; in cputime()
536 psecs += k->ki_p->ki_childtime.tv_usec; in cputime()
538 return (printtime(k, ve, secs, psecs)); in cputime()
542 cpunum(KINFO *k, VARENT *ve __unused) in cpunum() argument
546 if (k->ki_p->ki_stat == SRUN && k->ki_p->ki_oncpu != NOCPU) { in cpunum()
547 asprintf(&cpu, "%d", k->ki_p->ki_oncpu); in cpunum()
549 asprintf(&cpu, "%d", k->ki_p->ki_lastcpu); in cpunum()
555 systime(KINFO *k, VARENT *ve) in systime() argument
559 secs = k->ki_p->ki_rusage.ru_stime.tv_sec; in systime()
560 psecs = k->ki_p->ki_rusage.ru_stime.tv_usec; in systime()
562 secs += k->ki_p->ki_childstime.tv_sec; in systime()
563 psecs += k->ki_p->ki_childstime.tv_usec; in systime()
565 return (printtime(k, ve, secs, psecs)); in systime()
569 usertime(KINFO *k, VARENT *ve) in usertime() argument
573 secs = k->ki_p->ki_rusage.ru_utime.tv_sec; in usertime()
574 psecs = k->ki_p->ki_rusage.ru_utime.tv_usec; in usertime()
576 secs += k->ki_p->ki_childutime.tv_sec; in usertime()
577 psecs += k->ki_p->ki_childutime.tv_usec; in usertime()
579 return (printtime(k, ve, secs, psecs)); in usertime()
583 elapsed(KINFO *k, VARENT *ve __unused) in elapsed() argument
589 if (!k->ki_valid) in elapsed()
591 val = now - k->ki_p->ki_start.tv_sec; in elapsed()
609 elapseds(KINFO *k, VARENT *ve __unused) in elapseds() argument
614 if (!k->ki_valid) in elapseds()
616 val = now - k->ki_p->ki_start.tv_sec; in elapseds()
622 getpcpu(const KINFO *k) in getpcpu() argument
634 if (k->ki_p->ki_swtime == 0) in getpcpu()
637 return (100.0 * fxtofl(k->ki_p->ki_pctcpu)); in getpcpu()
638 return (100.0 * fxtofl(k->ki_p->ki_pctcpu) / in getpcpu()
639 (1.0 - exp(k->ki_p->ki_swtime * log(fxtofl(ccpu))))); in getpcpu()
643 pcpu(KINFO *k, VARENT *ve __unused) in pcpu() argument
647 asprintf(&str, "%.1f", getpcpu(k)); in pcpu()
652 getpmem(KINFO *k) in getpmem() argument
664 fracmem = ((double)k->ki_p->ki_rssize) / mempages; in getpmem()
669 pmem(KINFO *k, VARENT *ve __unused) in pmem() argument
673 asprintf(&str, "%.1f", getpmem(k)); in pmem()
678 pagein(KINFO *k, VARENT *ve __unused) in pagein() argument
682 asprintf(&str, "%ld", k->ki_valid ? k->ki_p->ki_rusage.ru_majflt : 0); in pagein()
688 maxrss(KINFO *k __unused, VARENT *ve __unused) in maxrss()
696 priorityr(KINFO *k, VARENT *ve __unused) in priorityr() argument
702 lpri = &k->ki_p->ki_pri; in priorityr()
743 cp = ofmt + 1; in printval()
786 kvar(KINFO *k, VARENT *ve) in kvar() argument
791 return (printval((char *)((char *)k->ki_p + v->off), v)); in kvar()
795 rvar(KINFO *k, VARENT *ve) in rvar() argument
800 if (!k->ki_valid) in rvar()
802 return (printval((char *)((char *)(&k->ki_p->ki_rusage) + v->off), v)); in rvar()
806 emulname(KINFO *k, VARENT *ve __unused) in emulname() argument
809 return (strdup(k->ki_p->ki_emul)); in emulname()
813 label(KINFO *k, VARENT *ve __unused) in label() argument
820 if (mac_prepare_process_label(&proclabel) == -1) { in label()
824 error = mac_get_pid(k->ki_p->ki_pid, proclabel); in label()
826 if (mac_to_text(proclabel, &string) == -1) in label()
835 loginclass(KINFO *k, VARENT *ve __unused) in loginclass() argument
843 if (k->ki_p->ki_flag & P_SYSTEM) { in loginclass()
846 return (strdup(k->ki_p->ki_loginclass)); in loginclass()
850 jailname(KINFO *k, VARENT *ve __unused) in jailname() argument
854 if (k->ki_p->ki_jid == 0) in jailname()
856 name = jail_getname(k->ki_p->ki_jid); in jailname()