GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: bin/ps/print.c Lines: 281 327 85.9 %
Date: 2017-11-07 Branches: 140 208 67.3 %

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
1414
	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
7924
	if (!needheader)
79
		return;
80
22406
	for (vent = vhead; vent; vent = vent->next) {
81
7241
		v = vent->var;
82
7241
		if (v->flag & LJUST) {
83
4693
			if (vent->next == NULL)	/* last one */
84
3203
				(void)printf("%s", v->header);
85
			else
86
1490
				(void)printf("%-*s", v->width, v->header);
87
		} else
88
2548
			(void)printf("%*s", v->width, v->header);
89
7241
		if (vent->next != NULL)
90
6558
			(void)putchar(' ');
91
	}
92
7924
	(void)putchar('\n');
93
7924
}
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
4400
	v = ve->var;
110
2200
	if (ve->next != NULL || termwidth != UNLIMITED) {
111
1972
		if (ve->next == NULL) {
112
781
			left = termwidth - (totwidth - v->width);
113
781
			if (left < 1) /* already wrapped, just use std width */
114
92
				left = v->width;
115
		} else
116
1191
			left = v->width;
117
	} else
118
		left = INT_MAX;
119
120
2200
	if (needenv && kd != NULL) {
121
805
		argv = kvm_getenvv(kd, kp, termwidth);
122
805
		if ((p = argv) != NULL) {
123
2323
			while (*p) {
124
943
				if (wantspace) {
125
276
					putchar(' ');
126
138
					left--;
127
138
				}
128
943
				left -= mbswprint(*p, left, 0);
129
943
				if (left == 0)
130
184
					return;
131
759
				p++;
132
				wantspace = 1;
133
			}
134
		}
135
	} else
136
		argv = NULL;
137
138
2016
	if (needcomm) {
139
2016
		if (!commandonly) {
140
1556
			if (kd != NULL) {
141
1556
				argv = kvm_getargv(kd, kp, termwidth);
142
1556
				if ((p = argv) != NULL) {
143
4216
					while (*p) {
144
1972
						if (wantspace) {
145
1660
							putchar(' ');
146
830
							left--;
147
830
						}
148
1972
						left -= mbswprint(*p, left, 0);
149
1972
						if (left == 0)
150
435
							return;
151
1537
						p++;
152
						wantspace = 1;
153
					}
154
				}
155
			}
156

2535
			if (argv == NULL || argv[0] == '\0' ||
157
707
			    strcmp(cmdpart(argv[0]), kp->p_comm)) {
158
501
				if (wantspace) {
159
1002
					putchar(' ');
160
501
					if (--left == 0)
161
23
						return;
162
				}
163
956
				putchar('(');
164
478
				left--;
165
478
				left -= mbswprint(kp->p_comm, left, 0);
166
478
				if (left == 0)
167
276
					return;
168
404
				putchar(')');
169
202
				left--;
170
202
			}
171
		} else {
172
460
			if (wantspace) {
173
414
				putchar(' ');
174
207
				left--;
175
207
			}
176
460
			left -= mbswprint(kp->p_comm, left, 0);
177
		}
178
	}
179
1282
	if (ve->next != NULL)
180
2267
		while (left-- > 0)
181
3528
			putchar(' ');
182
3482
}
183
184
void
185
ucomm(const struct kinfo_proc *kp, VARENT *ve)
186
{
187
1676
	mbswprint(kp->p_comm, ve->var->width, ve->next != NULL);
188
838
}
189
190
void
191
curwd(const struct kinfo_proc *kp, VARENT *ve)
192
{
193
1264
	int name[] = { CTL_KERN, KERN_PROC_CWD, kp->p_pid };
194
632
	char path[PATH_MAX];
195
632
	size_t pathlen = sizeof path;
196
197

1264
	if (!kvm_sysctl_only || sysctl(name, 3, path, &pathlen, NULL, 0) != 0)
198
		*path = '\0';
199
200
632
	mbswprint(path, ve->var->width, ve->next != NULL);
201
632
}
202
203
void
204
logname(const struct kinfo_proc *kp, VARENT *ve)
205
{
206
	VAR *v;
207
208
960
	v = ve->var;
209
480
	if (kp->p_login[0]) {
210
960
		int n = min(v->width, LOGIN_NAME_MAX);
211
480
		mbswprint(kp->p_login, n, ve->next != NULL);
212
480
		if (ve->next != NULL)
213
457
			while (n++ < v->width)
214
				putchar(' ');
215
480
	} else
216
		(void)printf("%-*s", v->width, "-");
217
480
}
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
822
	char buf[16];
228
229
411
	v = ve->var;
230
411
	flag = kp->p_flag;
231
411
	cp = buf;
232
233

411
	switch (kp->p_stat) {
234
235
	case SSTOP:
236
		*cp = 'T';
237
		break;
238
239
	case SSLEEP:
240
388
		if (flag & P_SINTR)	/* interruptible (long) */
241
388
			*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
23
		state = *cp = 'R';
250
23
		break;
251
252
	case SDEAD:
253
		*cp = 'Z';
254
		break;
255
256
	default:
257
		*cp = '?';
258
	}
259
411
	cp++;
260
261
411
	if (kp->p_nice < NZERO)
262
		*cp++ = '<';
263
411
	else if (kp->p_nice > NZERO)
264
		*cp++ = 'N';
265
411
	if (kp->p_psflags & PS_TRACED)
266
		*cp++ = 'X';
267
411
	if ((kp->p_psflags & (PS_EXITING | PS_ZOMBIE)) == PS_EXITING)
268
		*cp++ = 'E';
269
411
	if (kp->p_psflags & PS_ISPWAIT)
270
		*cp++ = 'V';
271
411
	if (flag & P_SYSTEM)
272
		*cp++ = 'K';
273

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

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

434
	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
411
	(void)printf("%-*s", v->width, buf);
294
411
}
295
296
void
297
pri(const struct kinfo_proc *kp, VARENT *ve)
298
{
299
	VAR *v;
300
301
822
	v = ve->var;
302
411
	(void)printf("%*d", v->width, kp->p_priority - PZERO);
303
411
}
304
305
void
306
pnice(const struct kinfo_proc *kp, VARENT *ve)
307
{
308
	VAR *v;
309
822
	v = ve->var;
310
411
	(void)printf("%*d", v->width, kp->p_nice - NZERO);
311
411
}
312
313
void
314
euname(const struct kinfo_proc *kp, VARENT *ve)
315
{
316
1440
	mbswprint(user_from_uid(kp->p_uid, 0), ve->var->width,
317
480
	    ve->next != NULL);
318
480
}
319
320
void
321
runame(const struct kinfo_proc *kp, VARENT *ve)
322
{
323
1440
	mbswprint(user_from_uid(kp->p_ruid, 0), ve->var->width,
324
480
	    ve->next != NULL);
325
480
}
326
327
void
328
gname(const struct kinfo_proc *kp, VARENT *ve)
329
{
330
1440
	mbswprint(group_from_gid(kp->p_gid, 0), ve->var->width,
331
480
	    ve->next != NULL);
332
480
}
333
334
void
335
rgname(const struct kinfo_proc *kp, VARENT *ve)
336
{
337
1440
	mbswprint(group_from_gid(kp->p_rgid, 0), ve->var->width,
338
480
	    ve->next != NULL);
339
480
}
340
341
void
342
tdev(const struct kinfo_proc *kp, VARENT *ve)
343
{
344
	VAR *v;
345
	dev_t dev;
346
822
	char buff[16];
347
348
411
	v = ve->var;
349
411
	dev = kp->p_tdev;
350
411
	if (dev == NODEV)
351
		(void)printf("%*s", v->width, "??");
352
	else {
353
822
		(void)snprintf(buff, sizeof(buff),
354
411
		    "%d/%d", major(dev), minor(dev));
355
411
		(void)printf("%*s", v->width, buff);
356
	}
357
411
}
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
822
	v = ve->var;
367
411
	dev = kp->p_tdev;
368

822
	if (dev == NODEV || (ttname = devname(dev, S_IFCHR)) == NULL)
369
		(void)printf("%-*s", v->width, "??");
370
	else {
371
411
		if (strncmp(ttname, "tty", 3) == 0)
372
411
			ttname += 3;
373
822
		(void)printf("%*.*s%c", v->width-1, v->width-1, ttname,
374
411
			kp->p_eflag & EPROC_CTTY ? ' ' : '-');
375
	}
376
411
}
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
822
	v = ve->var;
386
411
	dev = kp->p_tdev;
387

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

822
	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
411
		secs = kp->p_rtime_sec;
546
411
		psecs = kp->p_rtime_usec;
547
411
		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
411
		psecs = (psecs + 5000) / 10000;
555
411
		secs += psecs / 100;
556
411
		psecs = psecs % 100;
557
	}
558
822
	(void)snprintf(obuff, sizeof(obuff),
559
411
	    "%3ld:%02ld.%02ld", secs/60, secs%60, psecs);
560
411
	(void)printf("%*s", v->width, obuff);
561
411
}
562
563
double
564
getpcpu(const struct kinfo_proc *kp)
565
{
566
822
	if (fscale == 0)
567
		return (0.0);
568
569
#define	fxtofl(fixpt)	((double)(fixpt) / fscale)
570
571
411
	return (100.0 * fxtofl(kp->p_pctcpu));
572
411
}
573
574
void
575
pcpu(const struct kinfo_proc *kp, VARENT *ve)
576
{
577
	VAR *v;
578
579
822
	v = ve->var;
580
411
	(void)printf("%*.1f", v->width, getpcpu(kp));
581
411
}
582
583
double
584
getpmem(const struct kinfo_proc *kp)
585
{
586
	double fracmem;
587
588
822
	if (mempages == 0)
589
		return (0.0);
590
591
411
	if (kp->p_flag & P_SYSTEM)
592
		return (0.0);
593
	/* XXX don't have info about shared */
594
411
	fracmem = ((float)kp->p_vm_rssize)/mempages;
595
411
	return (100.0 * fracmem);
596
411
}
597
598
void
599
pmem(const struct kinfo_proc *kp, VARENT *ve)
600
{
601
	VAR *v;
602
603
822
	v = ve->var;
604
411
	(void)printf("%*.1f", v->width, getpmem(kp));
605
411
}
606
607
void
608
pagein(const struct kinfo_proc *kp, VARENT *ve)
609
{
610
	VAR *v;
611
612
822
	v = ve->var;
613
822
	(void)printf("%*llu", v->width,
614
1233
	    kp->p_uvalid ? kp->p_uru_majflt : 0);
615
411
}
616
617
void
618
maxrss(const struct kinfo_proc *kp, VARENT *ve)
619
{
620
	VAR *v;
621
622
822
	v = ve->var;
623
411
	(void)printf("%*llu", v->width, kp->p_rlim_rss_cur / 1024);
624
411
}
625
626
void
627
tsize(const struct kinfo_proc *kp, VARENT *ve)
628
{
629
	VAR *v;
630
631
822
	v = ve->var;
632
411
	(void)printf("%*llu", v->width, pgtok(kp->p_vm_tsize));
633
411
}
634
635
void
636
dsize(const struct kinfo_proc *kp, VARENT *ve)
637
{
638
	VAR *v;
639
640
822
	v = ve->var;
641
411
	(void)printf("%*llu", v->width, pgtok(kp->p_vm_dsize));
642
411
}
643
644
void
645
ssize(const struct kinfo_proc *kp, VARENT *ve)
646
{
647
	VAR *v;
648
649
822
	v = ve->var;
650
411
	(void)printf("%*llu", v->width, pgtok(kp->p_vm_ssize));
651
411
}
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
40446
	char ofmt[32];
661
662
40446
	snprintf(ofmt, sizeof(ofmt), "%%%s*%s", (v->flag & LJUST) ? "-" : "",
663
20223
	    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


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

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

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

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

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

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