Deleted Added
full compact
procstat.c (230917) procstat.c (230918)
1/*-
2 * Copyright (c) 2007, 2011 Robert N. M. Watson
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 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 *
1/*-
2 * Copyright (c) 2007, 2011 Robert N. M. Watson
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 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 *
26 * $FreeBSD: stable/9/usr.bin/procstat/procstat.c 230917 2012-02-02 18:17:49Z trociny $
26 * $FreeBSD: stable/9/usr.bin/procstat/procstat.c 230918 2012-02-02 18:22:25Z trociny $
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 <stdlib.h>
37#include <sysexits.h>
38#include <unistd.h>
39
40#include "procstat.h"
41
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 <stdlib.h>
37#include <sysexits.h>
38#include <unistd.h>
39
40#include "procstat.h"
41
42static int aflag, bflag, cflag, eflag, fflag, iflag, jflag, kflag, sflag, tflag;
43static int vflag, xflag;
42static int aflag, bflag, cflag, eflag, fflag, iflag, jflag, kflag, lflag, sflag;
43static int tflag, vflag, xflag;
44int hflag, nflag, Cflag;
45
46static void
47usage(void)
48{
49
50 fprintf(stderr, "usage: procstat [-h] [-C] [-M core] [-N system] "
51 "[-w interval] \n");
52 fprintf(stderr, " [-b | -c | -e | -f | -i | -j | -k | "
44int hflag, nflag, Cflag;
45
46static void
47usage(void)
48{
49
50 fprintf(stderr, "usage: procstat [-h] [-C] [-M core] [-N system] "
51 "[-w interval] \n");
52 fprintf(stderr, " [-b | -c | -e | -f | -i | -j | -k | "
53 "-s | -t | -v | -x] [-a | pid ...]\n");
53 "-l | -s | -t | -v | -x] [-a | pid ...]\n");
54 exit(EX_USAGE);
55}
56
57static void
58procstat(struct procstat *prstat, struct kinfo_proc *kipp)
59{
60
61 if (bflag)

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

67 else if (fflag)
68 procstat_files(prstat, kipp);
69 else if (iflag)
70 procstat_sigs(prstat, kipp);
71 else if (jflag)
72 procstat_threads_sigs(prstat, kipp);
73 else if (kflag)
74 procstat_kstack(kipp, kflag);
54 exit(EX_USAGE);
55}
56
57static void
58procstat(struct procstat *prstat, struct kinfo_proc *kipp)
59{
60
61 if (bflag)

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

67 else if (fflag)
68 procstat_files(prstat, kipp);
69 else if (iflag)
70 procstat_sigs(prstat, kipp);
71 else if (jflag)
72 procstat_threads_sigs(prstat, kipp);
73 else if (kflag)
74 procstat_kstack(kipp, kflag);
75 else if (lflag)
76 procstat_rlimit(kipp);
75 else if (sflag)
76 procstat_cred(kipp);
77 else if (tflag)
78 procstat_threads(kipp);
79 else if (vflag)
80 procstat_vm(kipp);
81 else if (xflag)
82 procstat_auxv(kipp);

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

118 long l;
119 pid_t pid;
120 char *dummy;
121 char *nlistf, *memf;
122 int cnt;
123
124 interval = 0;
125 memf = nlistf = NULL;
77 else if (sflag)
78 procstat_cred(kipp);
79 else if (tflag)
80 procstat_threads(kipp);
81 else if (vflag)
82 procstat_vm(kipp);
83 else if (xflag)
84 procstat_auxv(kipp);

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

120 long l;
121 pid_t pid;
122 char *dummy;
123 char *nlistf, *memf;
124 int cnt;
125
126 interval = 0;
127 memf = nlistf = NULL;
126 while ((ch = getopt(argc, argv, "CN:M:abcefijkhstvw:x")) != -1) {
128 while ((ch = getopt(argc, argv, "CN:M:abcefijklhstvw:x")) != -1) {
127 switch (ch) {
128 case 'C':
129 Cflag++;
130 break;
131
132 case 'M':
133 memf = optarg;
134 break;

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

162 case 'j':
163 jflag++;
164 break;
165
166 case 'k':
167 kflag++;
168 break;
169
129 switch (ch) {
130 case 'C':
131 Cflag++;
132 break;
133
134 case 'M':
135 memf = optarg;
136 break;

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

164 case 'j':
165 jflag++;
166 break;
167
168 case 'k':
169 kflag++;
170 break;
171
172 case 'l':
173 lflag++;
174 break;
175
170 case 'n':
171 nflag++;
172 break;
173
174 case 'h':
175 hflag++;
176 break;
177

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

205 usage();
206 }
207
208 }
209 argc -= optind;
210 argv += optind;
211
212 /* We require that either 0 or 1 mode flags be set. */
176 case 'n':
177 nflag++;
178 break;
179
180 case 'h':
181 hflag++;
182 break;
183

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

211 usage();
212 }
213
214 }
215 argc -= optind;
216 argv += optind;
217
218 /* We require that either 0 or 1 mode flags be set. */
213 tmp = bflag + cflag + eflag + fflag + (kflag ? 1 : 0) + sflag + tflag +
214 vflag + xflag;
219 tmp = bflag + cflag + eflag + fflag + (kflag ? 1 : 0) + lflag + sflag +
220 tflag + vflag + xflag;
215 if (!(tmp == 0 || tmp == 1))
216 usage();
217
218 /* We allow -k to be specified up to twice, but not more. */
219 if (kflag > 2)
220 usage();
221
222 /* Must specify either the -a flag or a list of pids. */

--- 51 unchanged lines hidden ---
221 if (!(tmp == 0 || tmp == 1))
222 usage();
223
224 /* We allow -k to be specified up to twice, but not more. */
225 if (kflag > 2)
226 usage();
227
228 /* Must specify either the -a flag or a list of pids. */

--- 51 unchanged lines hidden ---