GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: bin/ps/print.c Lines: 280 327 85.6 %
Date: 2017-11-13 Branches: 137 208 65.9 %

Line Branch Exec Source
1
/*	$OpenBSD: print.c,v 1.69 2016/09/08 15:11:29 tedu Exp $	*/
2
/*	$NetBSD: print.c,v 1.27 1995/09/29 21:58:12 cgd Exp $	*/
3
4
/*-
5
 * Copyright (c) 1990, 1993, 1994
6
 *	The Regents of the University of California.  All rights reserved.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice, this list of conditions and the following disclaimer.
13
 * 2. Redistributions in binary form must reproduce the above copyright
14
 *    notice, this list of conditions and the following disclaimer in the
15
 *    documentation and/or other materials provided with the distribution.
16
 * 3. Neither the name of the University nor the names of its contributors
17
 *    may be used to endorse or promote products derived from this software
18
 *    without specific prior written permission.
19
 *
20
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30
 * SUCH DAMAGE.
31
 */
32
33
#include <sys/param.h>	/* MAXCOMLEN PZERO NODEV */
34
#include <sys/types.h>
35
#include <sys/proc.h>
36
#include <sys/stat.h>
37
38
#include <sys/sysctl.h>
39
40
#include <err.h>
41
#include <grp.h>
42
#include <kvm.h>
43
#include <math.h>
44
#include <nlist.h>
45
#include <stddef.h>
46
#include <stdio.h>
47
#include <stdlib.h>
48
#include <string.h>
49
#include <unistd.h>
50
#include <limits.h>
51
#include <pwd.h>
52
53
#include "ps.h"
54
55
extern kvm_t *kd;
56
extern int needenv, needcomm, neednlist, commandonly;
57
58
int mbswprint(const char *, int, int);  /* utf8.c */
59
60
static char *cmdpart(char *);
61
62
#define	min(a,b)	((a) < (b) ? (a) : (b))
63
64
static char *
65
cmdpart(char *arg0)
66
{
67
	char *cp;
68
69
374
	return ((cp = strrchr(arg0, '/')) != NULL ? cp + 1 : arg0);
70
}
71
72
void
73
printheader(void)
74
{
75
	VAR *v;
76
	struct varent *vent;
77
78
1790
	if (!needheader)
79
		return;
80
5840
	for (vent = vhead; vent; vent = vent->next) {
81
2025
		v = vent->var;
82
2025
		if (v->flag & LJUST) {
83
1111
			if (vent->next == NULL)	/* last one */
84
726
				(void)printf("%s", v->header);
85
			else
86
385
				(void)printf("%-*s", v->width, v->header);
87
		} else
88
914
			(void)printf("%*s", v->width, v->header);
89
2025
		if (vent->next != NULL)
90
2260
			(void)putchar(' ');
91
	}
92
1790
	(void)putchar('\n');
93
1790
}
94
95
void
96
command(const struct kinfo_proc *kp, VARENT *ve)
97
{
98
	VAR *v;
99
	int left, wantspace = 0;
100
	char **argv, **p;
101
102
	/*
103
	 * Determine the available number of display columns.
104
	 * Always decrement and check after writing.
105
	 * No check is needed before mbswprint()
106
	 * and after writing the last data, though.
107
	 */
108
109
1098
	v = ve->var;
110
549
	if (ve->next != NULL || termwidth != UNLIMITED) {
111
499
		if (ve->next == NULL) {
112
170
			left = termwidth - (totwidth - v->width);
113
170
			if (left < 1) /* already wrapped, just use std width */
114
20
				left = v->width;
115
		} else
116
329
			left = v->width;
117
	} else
118
		left = INT_MAX;
119
120
549
	if (needenv && kd != NULL) {
121
175
		argv = kvm_getenvv(kd, kp, termwidth);
122
175
		if ((p = argv) != NULL) {
123
680
			while (*p) {
124
205
				if (wantspace) {
125
60
					putchar(' ');
126
30
					left--;
127
30
				}
128
205
				left -= mbswprint(*p, left, 0);
129
205
				if (left == 0)
130
40
					return;
131
165
				p++;
132
				wantspace = 1;
133
			}
134
		}
135
	} else
136
		argv = NULL;
137
138
509
	if (needcomm) {
139
509
		if (!commandonly) {
140
409
			if (kd != NULL) {
141
409
				argv = kvm_getargv(kd, kp, termwidth);
142
409
				if ((p = argv) != NULL) {
143
1460
					while (*p) {
144
543
						if (wantspace) {
145
448
							putchar(' ');
146
224
							left--;
147
224
						}
148
543
						left -= mbswprint(*p, left, 0);
149
543
						if (left == 0)
150
132
							return;
151
411
						p++;
152
						wantspace = 1;
153
					}
154
				}
155
			}
156

651
			if (argv == NULL || argv[0] == '\0' ||
157
187
			    strcmp(cmdpart(argv[0]), kp->p_comm)) {
158
127
				if (wantspace) {
159
254
					putchar(' ');
160
127
					if (--left == 0)
161
5
						return;
162
				}
163
244
				putchar('(');
164
122
				left--;
165
122
				left -= mbswprint(kp->p_comm, left, 0);
166
122
				if (left == 0)
167
60
					return;
168
124
				putchar(')');
169
62
				left--;
170
62
			}
171
		} else {
172
100
			if (wantspace) {
173
90
				putchar(' ');
174
45
				left--;
175
45
			}
176
100
			left -= mbswprint(kp->p_comm, left, 0);
177
		}
178
	}
179
312
	if (ve->next != NULL)
180
1422
		while (left-- > 0)
181
1138
			putchar(' ');
182
861
}
183
184
void
185
ucomm(const struct kinfo_proc *kp, VARENT *ve)
186
{
187
854
	mbswprint(kp->p_comm, ve->var->width, ve->next != NULL);
188
427
}
189
190
void
191
curwd(const struct kinfo_proc *kp, VARENT *ve)
192
{
193
418
	int name[] = { CTL_KERN, KERN_PROC_CWD, kp->p_pid };
194
209
	char path[PATH_MAX];
195
209
	size_t pathlen = sizeof path;
196
197

418
	if (!kvm_sysctl_only || sysctl(name, 3, path, &pathlen, NULL, 0) != 0)
198
		*path = '\0';
199
200
209
	mbswprint(path, ve->var->width, ve->next != NULL);
201
209
}
202
203
void
204
logname(const struct kinfo_proc *kp, VARENT *ve)
205
{
206
	VAR *v;
207
208
348
	v = ve->var;
209
174
	if (kp->p_login[0]) {
210
348
		int n = min(v->width, LOGIN_NAME_MAX);
211
174
		mbswprint(kp->p_login, n, ve->next != NULL);
212
174
		if (ve->next != NULL)
213
338
			while (n++ < v->width)
214
				putchar(' ');
215
174
	} else
216
		(void)printf("%-*s", v->width, "-");
217
174
}
218
219
#define pgtok(a)	(((unsigned long long)(a)*getpagesize())/1024)
220
221
void
222
printstate(const struct kinfo_proc *kp, VARENT *ve)
223
{
224
	int flag;
225
	char *cp, state = '\0';
226
	VAR *v;
227
318
	char buf[16];
228
229
159
	v = ve->var;
230
159
	flag = kp->p_flag;
231
159
	cp = buf;
232
233

159
	switch (kp->p_stat) {
234
235
	case SSTOP:
236
		*cp = 'T';
237
		break;
238
239
	case SSLEEP:
240
150
		if (flag & P_SINTR)	/* interruptible (long) */
241
150
			*cp = kp->p_slptime >= maxslp ? 'I' : 'S';
242
		else
243
			*cp = 'D';
244
		break;
245
246
	case SRUN:
247
	case SIDL:
248
	case SONPROC:
249
9
		state = *cp = 'R';
250
9
		break;
251
252
	case SDEAD:
253
		*cp = 'Z';
254
		break;
255
256
	default:
257
		*cp = '?';
258
	}
259
159
	cp++;
260
261
159
	if (kp->p_nice < NZERO)
262
		*cp++ = '<';
263
159
	else if (kp->p_nice > NZERO)
264
		*cp++ = 'N';
265
159
	if (kp->p_psflags & PS_TRACED)
266
		*cp++ = 'X';
267
159
	if ((kp->p_psflags & (PS_EXITING | PS_ZOMBIE)) == PS_EXITING)
268
		*cp++ = 'E';
269
159
	if (kp->p_psflags & PS_ISPWAIT)
270
		*cp++ = 'V';
271
159
	if (flag & P_SYSTEM)
272
		*cp++ = 'K';
273

318
	if ((flag & P_SYSTEM) == 0 &&
274
159
	    kp->p_rlim_rss_cur / 1024 < pgtok(kp->p_vm_rssize))
275
		*cp++ = '>';
276
159
	if (kp->p_eflag & EPROC_SLEADER)
277
73
		*cp++ = 's';
278

318
	if ((kp->p_psflags & PS_CONTROLT) && kp->p__pgid == kp->p_tpgid)
279
141
		*cp++ = '+';
280
159
	if (kp->p_psflags & PS_PLEDGE)
281
159
		*cp++ = 'p';
282
159
	*cp = '\0';
283
284

168
	if (state == 'R' && kp->p_cpuid != KI_NOCPU) {
285
		char pbuf[16];
286
287
		snprintf(pbuf, sizeof pbuf, "/%llu", kp->p_cpuid);
288
		*++cp = '\0';
289
		strlcat(buf, pbuf, sizeof buf);
290
		cp = buf + strlen(buf);
291
	}
292
293
159
	(void)printf("%-*s", v->width, buf);
294
159
}
295
296
void
297
pri(const struct kinfo_proc *kp, VARENT *ve)
298
{
299
	VAR *v;
300
301
318
	v = ve->var;
302
159
	(void)printf("%*d", v->width, kp->p_priority - PZERO);
303
159
}
304
305
void
306
pnice(const struct kinfo_proc *kp, VARENT *ve)
307
{
308
	VAR *v;
309
318
	v = ve->var;
310
159
	(void)printf("%*d", v->width, kp->p_nice - NZERO);
311
159
}
312
313
void
314
euname(const struct kinfo_proc *kp, VARENT *ve)
315
{
316
522
	mbswprint(user_from_uid(kp->p_uid, 0), ve->var->width,
317
174
	    ve->next != NULL);
318
174
}
319
320
void
321
runame(const struct kinfo_proc *kp, VARENT *ve)
322
{
323
522
	mbswprint(user_from_uid(kp->p_ruid, 0), ve->var->width,
324
174
	    ve->next != NULL);
325
174
}
326
327
void
328
gname(const struct kinfo_proc *kp, VARENT *ve)
329
{
330
522
	mbswprint(group_from_gid(kp->p_gid, 0), ve->var->width,
331
174
	    ve->next != NULL);
332
174
}
333
334
void
335
rgname(const struct kinfo_proc *kp, VARENT *ve)
336
{
337
522
	mbswprint(group_from_gid(kp->p_rgid, 0), ve->var->width,
338
174
	    ve->next != NULL);
339
174
}
340
341
void
342
tdev(const struct kinfo_proc *kp, VARENT *ve)
343
{
344
	VAR *v;
345
	dev_t dev;
346
318
	char buff[16];
347
348
159
	v = ve->var;
349
159
	dev = kp->p_tdev;
350
159
	if (dev == NODEV)
351
		(void)printf("%*s", v->width, "??");
352
	else {
353
318
		(void)snprintf(buff, sizeof(buff),
354
159
		    "%d/%d", major(dev), minor(dev));
355
159
		(void)printf("%*s", v->width, buff);
356
	}
357
159
}
358
359
void
360
tname(const struct kinfo_proc *kp, VARENT *ve)
361
{
362
	VAR *v;
363
	dev_t dev;
364
	char *ttname;
365
366
318
	v = ve->var;
367
159
	dev = kp->p_tdev;
368

318
	if (dev == NODEV || (ttname = devname(dev, S_IFCHR)) == NULL)
369
		(void)printf("%-*s", v->width, "??");
370
	else {
371
159
		if (strncmp(ttname, "tty", 3) == 0)
372
159
			ttname += 3;
373
318
		(void)printf("%*.*s%c", v->width-1, v->width-1, ttname,
374
159
			kp->p_eflag & EPROC_CTTY ? ' ' : '-');
375
	}
376
159
}
377
378
void
379
longtname(const struct kinfo_proc *kp, VARENT *ve)
380
{
381
	VAR *v;
382
	dev_t dev;
383
	char *ttname;
384
385
318
	v = ve->var;
386
159
	dev = kp->p_tdev;
387

318
	if (dev == NODEV || (ttname = devname(dev, S_IFCHR)) == NULL)
388
		(void)printf("%-*s", v->width, "??");
389
	else
390
159
		(void)printf("%-*s", v->width, ttname);
391
159
}
392
393
void
394
started(const struct kinfo_proc *kp, VARENT *ve)
395
{
396
	VAR *v;
397
	static time_t now;
398
318
	time_t startt;
399
	struct tm *tp;
400
159
	char buf[100];
401
402
159
	v = ve->var;
403
159
	if (!kp->p_uvalid) {
404
		(void)printf("%-*s", v->width, "-");
405
		return;
406
	}
407
408
#define SECSPERHOUR	(60 * 60)
409
#define SECSPERDAY	(24 * 60 * 60)
410
411
159
	startt = kp->p_ustart_sec;
412
159
	tp = localtime(&startt);
413
159
	if (!now)
414
9
		(void)time(&now);
415
159
	if (now - kp->p_ustart_sec < 12 * SECSPERHOUR) {
416
87
		(void)strftime(buf, sizeof(buf) - 1, "%l:%M%p", tp);
417
159
	} else if (now - kp->p_ustart_sec < 7 * SECSPERDAY) {
418
72
		(void)strftime(buf, sizeof(buf) - 1, "%a%I%p", tp);
419
72
	} else
420
		(void)strftime(buf, sizeof(buf) - 1, "%e%b%y", tp);
421
159
	(void)printf("%-*s", v->width, buf);
422
318
}
423
424
void
425
lstarted(const struct kinfo_proc *kp, VARENT *ve)
426
{
427
	VAR *v;
428
318
	time_t startt;
429
159
	char buf[100];
430
431
159
	v = ve->var;
432
159
	if (!kp->p_uvalid) {
433
		(void)printf("%-*s", v->width, "-");
434
		return;
435
	}
436
159
	startt = kp->p_ustart_sec;
437
318
	(void)strftime(buf, sizeof(buf) -1, "%c",
438
159
	    localtime(&startt));
439
159
	(void)printf("%-*s", v->width, buf);
440
318
}
441
442
void elapsed(const struct kinfo_proc *kp, VARENT *ve)
443
{
444
	VAR *v;
445
	static time_t now;
446
	time_t secs;
447
318
	char buf[64];
448
	long days, hours, minutes, seconds;
449
450
159
	v = ve->var;
451
159
	if (!kp->p_uvalid) {
452
		(void)printf("%*s", v->width, "-");
453
		return;
454
	}
455
456
159
	if (!now)
457
9
		(void)time(&now);
458
159
	secs = now - kp->p_ustart_sec;
459
460
159
	if (secs < 0) {
461
		(void)printf("%*s", v->width, "-");
462
		return;
463
	}
464
465
159
	days = secs / SECSPERDAY;
466
159
	secs %= SECSPERDAY;
467
468
159
	hours = secs / SECSPERHOUR;
469
159
	secs %= SECSPERHOUR;
470
471
159
	minutes = secs / 60;
472
159
	seconds = secs % 60;
473
474
159
	if (days > 0)
475
		(void)snprintf(buf, sizeof(buf), "%ld-%02ld:%02ld:%02ld",
476
		    days, hours, minutes, seconds);
477
159
	else if (hours > 0)
478
72
		(void)snprintf(buf, sizeof(buf), "%02ld:%02ld:%02ld",
479
		    hours, minutes, seconds);
480
	else
481
87
		(void)snprintf(buf, sizeof(buf), "%02ld:%02ld",
482
		    minutes, seconds);
483
159
	(void)printf("%*s", v->width, buf);
484
318
}
485
486
void
487
wchan(const struct kinfo_proc *kp, VARENT *ve)
488
{
489
	VAR *v;
490
491
1056
	v = ve->var;
492
528
	if (kp->p_wmesg[0]) {
493
510
		(void)printf("%-*s", (int)v->width, kp->p_wmesg);
494
510
	} else
495
18
		(void)printf("%-*s", v->width, "-");
496
528
}
497
498
void
499
vsize(const struct kinfo_proc *kp, VARENT *ve)
500
{
501
	VAR *v;
502
503
318
	v = ve->var;
504
318
	(void)printf("%*llu", v->width,
505
159
	    pgtok(kp->p_vm_dsize + kp->p_vm_ssize + kp->p_vm_tsize));
506
159
}
507
508
void
509
rssize(const struct kinfo_proc *kp, VARENT *ve)
510
{
511
	VAR *v;
512
513
318
	v = ve->var;
514
	/* XXX don't have info about shared */
515
477
	(void)printf("%*llu", v->width, (kp->p_flag & P_SYSTEM) ? 0 :
516
159
	    pgtok(kp->p_vm_rssize));
517
159
}
518
519
void
520
p_rssize(const struct kinfo_proc *kp, VARENT *ve)
521
{
522
	VAR *v;
523
524
318
	v = ve->var;
525
477
	(void)printf("%*llu", v->width, (kp->p_flag & P_SYSTEM) ? 0 :
526
159
	    pgtok(kp->p_vm_rssize));
527
159
}
528
529
void
530
cputime(const struct kinfo_proc *kp, VARENT *ve)
531
{
532
	VAR *v;
533
	long secs;
534
	long psecs;	/* "parts" of a second. first micro, then centi */
535
318
	char obuff[128];
536
537
159
	v = ve->var;
538

318
	if (kp->p_stat == SDEAD || !kp->p_uvalid) {
539
		secs = 0;
540
		psecs = 0;
541
	} else {
542
		/*
543
		 * This counts time spent handling interrupts.  XXX
544
		 */
545
159
		secs = kp->p_rtime_sec;
546
159
		psecs = kp->p_rtime_usec;
547
159
		if (sumrusage) {
548
			secs += kp->p_uctime_sec;
549
			psecs += kp->p_uctime_usec;
550
		}
551
		/*
552
		 * round and scale to 100's
553
		 */
554
159
		psecs = (psecs + 5000) / 10000;
555
159
		secs += psecs / 100;
556
159
		psecs = psecs % 100;
557
	}
558
318
	(void)snprintf(obuff, sizeof(obuff),
559
159
	    "%3ld:%02ld.%02ld", secs/60, secs%60, psecs);
560
159
	(void)printf("%*s", v->width, obuff);
561
159
}
562
563
double
564
getpcpu(const struct kinfo_proc *kp)
565
{
566
318
	if (fscale == 0)
567
		return (0.0);
568
569
#define	fxtofl(fixpt)	((double)(fixpt) / fscale)
570
571
159
	return (100.0 * fxtofl(kp->p_pctcpu));
572
159
}
573
574
void
575
pcpu(const struct kinfo_proc *kp, VARENT *ve)
576
{
577
	VAR *v;
578
579
318
	v = ve->var;
580
159
	(void)printf("%*.1f", v->width, getpcpu(kp));
581
159
}
582
583
double
584
getpmem(const struct kinfo_proc *kp)
585
{
586
	double fracmem;
587
588
318
	if (mempages == 0)
589
		return (0.0);
590
591
159
	if (kp->p_flag & P_SYSTEM)
592
		return (0.0);
593
	/* XXX don't have info about shared */
594
159
	fracmem = ((float)kp->p_vm_rssize)/mempages;
595
159
	return (100.0 * fracmem);
596
159
}
597
598
void
599
pmem(const struct kinfo_proc *kp, VARENT *ve)
600
{
601
	VAR *v;
602
603
318
	v = ve->var;
604
159
	(void)printf("%*.1f", v->width, getpmem(kp));
605
159
}
606
607
void
608
pagein(const struct kinfo_proc *kp, VARENT *ve)
609
{
610
	VAR *v;
611
612
318
	v = ve->var;
613
318
	(void)printf("%*llu", v->width,
614
477
	    kp->p_uvalid ? kp->p_uru_majflt : 0);
615
159
}
616
617
void
618
maxrss(const struct kinfo_proc *kp, VARENT *ve)
619
{
620
	VAR *v;
621
622
318
	v = ve->var;
623
159
	(void)printf("%*llu", v->width, kp->p_rlim_rss_cur / 1024);
624
159
}
625
626
void
627
tsize(const struct kinfo_proc *kp, VARENT *ve)
628
{
629
	VAR *v;
630
631
318
	v = ve->var;
632
159
	(void)printf("%*llu", v->width, pgtok(kp->p_vm_tsize));
633
159
}
634
635
void
636
dsize(const struct kinfo_proc *kp, VARENT *ve)
637
{
638
	VAR *v;
639
640
318
	v = ve->var;
641
159
	(void)printf("%*llu", v->width, pgtok(kp->p_vm_dsize));
642
159
}
643
644
void
645
ssize(const struct kinfo_proc *kp, VARENT *ve)
646
{
647
	VAR *v;
648
649
318
	v = ve->var;
650
159
	(void)printf("%*llu", v->width, pgtok(kp->p_vm_ssize));
651
159
}
652
653
/*
654
 * Generic output routines.  Print fields from various prototype
655
 * structures.
656
 */
657
static void
658
printval(char *bp, VAR *v)
659
{
660
15762
	char ofmt[32];
661
662
15762
	snprintf(ofmt, sizeof(ofmt), "%%%s*%s", (v->flag & LJUST) ? "-" : "",
663
7881
	    v->fmt);
664
665
	/*
666
	 * Note that the "INF127" check is nonsensical for types
667
	 * that are or can be signed.
668
	 */
669
#define	GET(type)		(*(type *)bp)
670
#define	CHK_INF127(n)		(((n) > 127) && (v->flag & INF127) ? 127 : (n))
671
672


7881
	switch (v->type) {
673
	case INT8:
674
		(void)printf(ofmt, v->width, GET(int8_t));
675
		break;
676
	case UINT8:
677

477
		(void)printf(ofmt, v->width, CHK_INF127(GET(u_int8_t)));
678
159
		break;
679
	case INT16:
680
159
		(void)printf(ofmt, v->width, GET(int16_t));
681
159
		break;
682
	case UINT16:
683

954
		(void)printf(ofmt, v->width, CHK_INF127(GET(u_int16_t)));
684
318
		break;
685
	case INT32:
686
2316
		(void)printf(ofmt, v->width, GET(int32_t));
687
2316
		break;
688
	case UINT32:
689

6028
		(void)printf(ofmt, v->width, CHK_INF127(GET(u_int32_t)));
690
1908
		break;
691
	case INT64:
692
		(void)printf(ofmt, v->width, GET(int64_t));
693
		break;
694
	case UINT64:
695

10186
		(void)printf(ofmt, v->width, CHK_INF127(GET(u_int64_t)));
696
3021
		break;
697
	default:
698
		errx(1, "unknown type %d", v->type);
699
	}
700
#undef GET
701
#undef CHK_INF127
702
7881
}
703
704
void
705
pvar(const struct kinfo_proc *kp, VARENT *ve)
706
{
707
	VAR *v;
708
709
15762
	v = ve->var;
710

9630
	if ((v->flag & USER) && !kp->p_uvalid)
711
		(void)printf("%*s", v->width, "-");
712
	else
713
7881
		printval((char *)kp + v->off, v);
714
7881
}
715
716
void
717
emulname(const struct kinfo_proc *kp, VARENT *ve)
718
{
719
	VAR *v;
720
721
318
	v = ve->var;
722
723
159
	(void)printf("%-*s", (int)v->width, kp->p_emul);
724
159
}