Deleted Added
full compact
procstat_basic.c (221807) procstat_basic.c (287486)
1/*-
2 * Copyright (c) 2007 Robert N. M. Watson
1/*-
2 * Copyright (c) 2007 Robert N. M. Watson
3 * Copyright (c) 2015 Allan Jude <allanjude@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright

--- 7 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright

--- 7 unchanged lines hidden (view full) ---

19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
26 * $FreeBSD: head/usr.bin/procstat/procstat_basic.c 221807 2011-05-12 10:11:39Z stas $
27 * $FreeBSD: head/usr.bin/procstat/procstat_basic.c 287486 2015-09-05 17:02:01Z allanjude $
27 */
28
29#include <sys/param.h>
30#include <sys/sysctl.h>
31#include <sys/user.h>
32
33#include <err.h>
34#include <libprocstat.h>
35#include <stdio.h>
36#include <string.h>
37
38#include "procstat.h"
39
40void
41procstat_basic(struct kinfo_proc *kipp)
42{
43
44 if (!hflag)
28 */
29
30#include <sys/param.h>
31#include <sys/sysctl.h>
32#include <sys/user.h>
33
34#include <err.h>
35#include <libprocstat.h>
36#include <stdio.h>
37#include <string.h>
38
39#include "procstat.h"
40
41void
42procstat_basic(struct kinfo_proc *kipp)
43{
44
45 if (!hflag)
45 printf("%5s %5s %5s %5s %5s %3s %-8s %-9s %-13s %-12s\n",
46 xo_emit("{T:/%5s %5s %5s %5s %5s %3s %-8s %-9s %-13s %-12s}\n",
46 "PID", "PPID", "PGID", "SID", "TSID", "THR", "LOGIN",
47 "WCHAN", "EMUL", "COMM");
48
47 "PID", "PPID", "PGID", "SID", "TSID", "THR", "LOGIN",
48 "WCHAN", "EMUL", "COMM");
49
49 printf("%5d ", kipp->ki_pid);
50 printf("%5d ", kipp->ki_ppid);
51 printf("%5d ", kipp->ki_pgid);
52 printf("%5d ", kipp->ki_sid);
53 printf("%5d ", kipp->ki_tsid);
54 printf("%3d ", kipp->ki_numthreads);
55 printf("%-8s ", strlen(kipp->ki_login) ? kipp->ki_login : "-");
50 xo_emit("{k:process_id/%5d/%d} ", kipp->ki_pid);
51 xo_emit("{:parent_process_id/%5d/%d} ", kipp->ki_ppid);
52 xo_emit("{:process_group_id/%5d/%d} ", kipp->ki_pgid);
53 xo_emit("{:session_id/%5d/%d} ", kipp->ki_sid);
54 xo_emit("{:terminal_session_id/%5d/%d} ", kipp->ki_tsid);
55 xo_emit("{:threads/%3d/%d} ", kipp->ki_numthreads);
56 xo_emit("{:login/%-8s/%s} ", strlen(kipp->ki_login) ?
57 kipp->ki_login : "-");
56 if (kipp->ki_kiflag & KI_LOCKBLOCK) {
58 if (kipp->ki_kiflag & KI_LOCKBLOCK) {
57 printf("*%-8s ", strlen(kipp->ki_lockname) ?
59 xo_emit("{:lockname/*%-8s/%s} ", strlen(kipp->ki_lockname) ?
58 kipp->ki_lockname : "-");
59 } else {
60 kipp->ki_lockname : "-");
61 } else {
60 printf("%-9s ", strlen(kipp->ki_wmesg) ?
62 xo_emit("{:wait_channel/%-9s/%s} ", strlen(kipp->ki_wmesg) ?
61 kipp->ki_wmesg : "-");
62 }
63 kipp->ki_wmesg : "-");
64 }
63 printf("%-13s ", strcmp(kipp->ki_emul, "null") ? kipp->ki_emul : "-");
64 printf("%-12s\n", kipp->ki_comm);
65 xo_emit("{:emulation/%-13s/%s} ", strcmp(kipp->ki_emul, "null") ?
66 kipp->ki_emul : "-");
67 xo_emit("{:command/%-12s/%s}\n", kipp->ki_comm);
65}
68}