kern_sysctl.c revision 1.10 1 /* $NetBSD: kern_sysctl.c,v 1.10 1995/08/04 18:36:11 thorpej Exp $ */
2
3 /*-
4 * Copyright (c) 1982, 1986, 1989, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * Mike Karels at Berkeley Software Design, Inc.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the University of
21 * California, Berkeley and its contributors.
22 * 4. Neither the name of the University nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)kern_sysctl.c 8.4 (Berkeley) 4/14/94
39 */
40
41 /*
42 * sysctl system call.
43 */
44
45 #include <sys/param.h>
46 #include <sys/systm.h>
47 #include <sys/kernel.h>
48 #include <sys/malloc.h>
49 #include <sys/proc.h>
50 #include <sys/file.h>
51 #include <sys/vnode.h>
52 #include <sys/unistd.h>
53 #include <sys/buf.h>
54 #include <sys/ioctl.h>
55 #include <sys/tty.h>
56 #include <sys/disklabel.h>
57 #include <vm/vm.h>
58 #include <sys/sysctl.h>
59
60 #include <sys/mount.h>
61 #include <sys/syscallargs.h>
62
63 sysctlfn kern_sysctl;
64 sysctlfn hw_sysctl;
65 #ifdef DEBUG
66 sysctlfn debug_sysctl;
67 #endif
68 extern sysctlfn vm_sysctl;
69 extern sysctlfn fs_sysctl;
70 extern sysctlfn net_sysctl;
71 extern sysctlfn cpu_sysctl;
72
73 /*
74 * Locking and stats
75 */
76 static struct sysctl_lock {
77 int sl_lock;
78 int sl_want;
79 int sl_locked;
80 } memlock;
81
82 int
83 __sysctl(p, uap, retval)
84 struct proc *p;
85 register struct __sysctl_args /* {
86 syscallarg(int *) name;
87 syscallarg(u_int) namelen;
88 syscallarg(void *) old;
89 syscallarg(size_t *) oldlenp;
90 syscallarg(void *) new;
91 syscallarg(size_t) newlen;
92 } */ *uap;
93 register_t *retval;
94 {
95 int error, dolock = 1;
96 size_t savelen, oldlen = 0;
97 sysctlfn *fn;
98 int name[CTL_MAXNAME];
99
100 if (SCARG(uap, new) != NULL &&
101 (error = suser(p->p_ucred, &p->p_acflag)))
102 return (error);
103 /*
104 * all top-level sysctl names are non-terminal
105 */
106 if (SCARG(uap, namelen) > CTL_MAXNAME || SCARG(uap, namelen) < 2)
107 return (EINVAL);
108 if (error =
109 copyin(SCARG(uap, name), &name, SCARG(uap, namelen) * sizeof(int)))
110 return (error);
111
112 switch (name[0]) {
113 case CTL_KERN:
114 fn = kern_sysctl;
115 if (name[2] != KERN_VNODE) /* XXX */
116 dolock = 0;
117 break;
118 case CTL_HW:
119 fn = hw_sysctl;
120 break;
121 case CTL_VM:
122 fn = vm_sysctl;
123 break;
124 case CTL_NET:
125 fn = net_sysctl;
126 break;
127 #ifdef notyet
128 case CTL_FS:
129 fn = fs_sysctl;
130 break;
131 #endif
132 case CTL_MACHDEP:
133 fn = cpu_sysctl;
134 break;
135 #ifdef DEBUG
136 case CTL_DEBUG:
137 fn = debug_sysctl;
138 break;
139 #endif
140 default:
141 return (EOPNOTSUPP);
142 }
143
144 if (SCARG(uap, oldlenp) &&
145 (error = copyin(SCARG(uap, oldlenp), &oldlen, sizeof(oldlen))))
146 return (error);
147 if (SCARG(uap, old) != NULL) {
148 if (!useracc(SCARG(uap, old), oldlen, B_WRITE))
149 return (EFAULT);
150 while (memlock.sl_lock) {
151 memlock.sl_want = 1;
152 sleep((caddr_t)&memlock, PRIBIO+1);
153 memlock.sl_locked++;
154 }
155 memlock.sl_lock = 1;
156 if (dolock)
157 vslock(SCARG(uap, old), oldlen);
158 savelen = oldlen;
159 }
160 error = (*fn)(name + 1, SCARG(uap, namelen) - 1, SCARG(uap, old),
161 &oldlen, SCARG(uap, new), SCARG(uap, newlen), p);
162 if (SCARG(uap, old) != NULL) {
163 if (dolock)
164 vsunlock(SCARG(uap, old), savelen, B_WRITE);
165 memlock.sl_lock = 0;
166 if (memlock.sl_want) {
167 memlock.sl_want = 0;
168 wakeup((caddr_t)&memlock);
169 }
170 }
171 if (error)
172 return (error);
173 if (SCARG(uap, oldlenp))
174 error = copyout(&oldlen, SCARG(uap, oldlenp), sizeof(oldlen));
175 *retval = oldlen;
176 return (0);
177 }
178
179 /*
180 * Attributes stored in the kernel.
181 */
182 char hostname[MAXHOSTNAMELEN];
183 int hostnamelen;
184 char domainname[MAXHOSTNAMELEN];
185 int domainnamelen;
186 long hostid;
187 #ifdef INSECURE
188 int securelevel = -1;
189 #else
190 int securelevel;
191 #endif
192
193 /*
194 * kernel related system variables.
195 */
196 kern_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
197 int *name;
198 u_int namelen;
199 void *oldp;
200 size_t *oldlenp;
201 void *newp;
202 size_t newlen;
203 struct proc *p;
204 {
205 int error, level, inthostid;
206 extern char ostype[], osrelease[], version[];
207
208 /* all sysctl names at this level are terminal */
209 if (namelen != 1 && !(name[0] == KERN_PROC || name[0] == KERN_PROF))
210 return (ENOTDIR); /* overloaded */
211
212 switch (name[0]) {
213 case KERN_OSTYPE:
214 return (sysctl_rdstring(oldp, oldlenp, newp, ostype));
215 case KERN_OSRELEASE:
216 return (sysctl_rdstring(oldp, oldlenp, newp, osrelease));
217 case KERN_OSREV:
218 return (sysctl_rdint(oldp, oldlenp, newp, BSD));
219 case KERN_VERSION:
220 return (sysctl_rdstring(oldp, oldlenp, newp, version));
221 case KERN_MAXVNODES:
222 return(sysctl_int(oldp, oldlenp, newp, newlen, &desiredvnodes));
223 case KERN_MAXPROC:
224 return (sysctl_int(oldp, oldlenp, newp, newlen, &maxproc));
225 case KERN_MAXFILES:
226 return (sysctl_int(oldp, oldlenp, newp, newlen, &maxfiles));
227 case KERN_ARGMAX:
228 return (sysctl_rdint(oldp, oldlenp, newp, ARG_MAX));
229 case KERN_SECURELVL:
230 level = securelevel;
231 if ((error = sysctl_int(oldp, oldlenp, newp, newlen, &level)) ||
232 newp == NULL)
233 return (error);
234 if (level < securelevel && p->p_pid != 1)
235 return (EPERM);
236 securelevel = level;
237 return (0);
238 case KERN_HOSTNAME:
239 error = sysctl_string(oldp, oldlenp, newp, newlen,
240 hostname, sizeof(hostname));
241 if (newp && !error)
242 hostnamelen = newlen;
243 return (error);
244 case KERN_DOMAINNAME:
245 error = sysctl_string(oldp, oldlenp, newp, newlen,
246 domainname, sizeof(domainname));
247 if (newp && !error)
248 domainnamelen = newlen;
249 return (error);
250 case KERN_HOSTID:
251 inthostid = hostid; /* XXX assumes sizeof long <= sizeof int */
252 error = sysctl_int(oldp, oldlenp, newp, newlen, &inthostid);
253 hostid = inthostid;
254 return (error);
255 case KERN_CLOCKRATE:
256 return (sysctl_clockrate(oldp, oldlenp));
257 case KERN_BOOTTIME:
258 return (sysctl_rdstruct(oldp, oldlenp, newp, &boottime,
259 sizeof(struct timeval)));
260 case KERN_VNODE:
261 return (sysctl_vnode(oldp, oldlenp));
262 case KERN_PROC:
263 return (sysctl_doproc(name + 1, namelen - 1, oldp, oldlenp));
264 case KERN_FILE:
265 return (sysctl_file(oldp, oldlenp));
266 #ifdef GPROF
267 case KERN_PROF:
268 return (sysctl_doprof(name + 1, namelen - 1, oldp, oldlenp,
269 newp, newlen));
270 #endif
271 case KERN_POSIX1:
272 return (sysctl_rdint(oldp, oldlenp, newp, _POSIX_VERSION));
273 case KERN_NGROUPS:
274 return (sysctl_rdint(oldp, oldlenp, newp, NGROUPS_MAX));
275 case KERN_JOB_CONTROL:
276 return (sysctl_rdint(oldp, oldlenp, newp, 1));
277 case KERN_SAVED_IDS:
278 #ifdef _POSIX_SAVED_IDS
279 return (sysctl_rdint(oldp, oldlenp, newp, 1));
280 #else
281 return (sysctl_rdint(oldp, oldlenp, newp, 0));
282 #endif
283 case KERN_MAXPARTITIONS:
284 return (sysctl_rdint(oldp, oldlenp, newp, MAXPARTITIONS));
285 case KERN_RAWPARTITION:
286 return (sysctl_rdint(oldp, oldlenp, newp, RAW_PART));
287 default:
288 return (EOPNOTSUPP);
289 }
290 /* NOTREACHED */
291 }
292
293 /*
294 * hardware related system variables.
295 */
296 hw_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
297 int *name;
298 u_int namelen;
299 void *oldp;
300 size_t *oldlenp;
301 void *newp;
302 size_t newlen;
303 struct proc *p;
304 {
305 extern char machine[], cpu_model[];
306
307 /* all sysctl names at this level are terminal */
308 if (namelen != 1)
309 return (ENOTDIR); /* overloaded */
310
311 switch (name[0]) {
312 case HW_MACHINE:
313 return (sysctl_rdstring(oldp, oldlenp, newp, machine));
314 case HW_MODEL:
315 return (sysctl_rdstring(oldp, oldlenp, newp, cpu_model));
316 case HW_NCPU:
317 return (sysctl_rdint(oldp, oldlenp, newp, 1)); /* XXX */
318 case HW_BYTEORDER:
319 return (sysctl_rdint(oldp, oldlenp, newp, BYTE_ORDER));
320 case HW_PHYSMEM:
321 return (sysctl_rdint(oldp, oldlenp, newp, ctob(physmem)));
322 case HW_USERMEM:
323 return (sysctl_rdint(oldp, oldlenp, newp,
324 ctob(physmem - cnt.v_wire_count)));
325 case HW_PAGESIZE:
326 return (sysctl_rdint(oldp, oldlenp, newp, PAGE_SIZE));
327 default:
328 return (EOPNOTSUPP);
329 }
330 /* NOTREACHED */
331 }
332
333 #ifdef DEBUG
334 /*
335 * Debugging related system variables.
336 */
337 struct ctldebug debug0, debug1, debug2, debug3, debug4;
338 struct ctldebug debug5, debug6, debug7, debug8, debug9;
339 struct ctldebug debug10, debug11, debug12, debug13, debug14;
340 struct ctldebug debug15, debug16, debug17, debug18, debug19;
341 static struct ctldebug *debugvars[CTL_DEBUG_MAXID] = {
342 &debug0, &debug1, &debug2, &debug3, &debug4,
343 &debug5, &debug6, &debug7, &debug8, &debug9,
344 &debug10, &debug11, &debug12, &debug13, &debug14,
345 &debug15, &debug16, &debug17, &debug18, &debug19,
346 };
347 int
348 debug_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
349 int *name;
350 u_int namelen;
351 void *oldp;
352 size_t *oldlenp;
353 void *newp;
354 size_t newlen;
355 struct proc *p;
356 {
357 struct ctldebug *cdp;
358
359 /* all sysctl names at this level are name and field */
360 if (namelen != 2)
361 return (ENOTDIR); /* overloaded */
362 cdp = debugvars[name[0]];
363 if (cdp->debugname == 0)
364 return (EOPNOTSUPP);
365 switch (name[1]) {
366 case CTL_DEBUG_NAME:
367 return (sysctl_rdstring(oldp, oldlenp, newp, cdp->debugname));
368 case CTL_DEBUG_VALUE:
369 return (sysctl_int(oldp, oldlenp, newp, newlen, cdp->debugvar));
370 default:
371 return (EOPNOTSUPP);
372 }
373 /* NOTREACHED */
374 }
375 #endif /* DEBUG */
376
377 /*
378 * Validate parameters and get old / set new parameters
379 * for an integer-valued sysctl function.
380 */
381 sysctl_int(oldp, oldlenp, newp, newlen, valp)
382 void *oldp;
383 size_t *oldlenp;
384 void *newp;
385 size_t newlen;
386 int *valp;
387 {
388 int error = 0;
389
390 if (oldp && *oldlenp < sizeof(int))
391 return (ENOMEM);
392 if (newp && newlen != sizeof(int))
393 return (EINVAL);
394 *oldlenp = sizeof(int);
395 if (oldp)
396 error = copyout(valp, oldp, sizeof(int));
397 if (error == 0 && newp)
398 error = copyin(newp, valp, sizeof(int));
399 return (error);
400 }
401
402 /*
403 * As above, but read-only.
404 */
405 sysctl_rdint(oldp, oldlenp, newp, val)
406 void *oldp;
407 size_t *oldlenp;
408 void *newp;
409 int val;
410 {
411 int error = 0;
412
413 if (oldp && *oldlenp < sizeof(int))
414 return (ENOMEM);
415 if (newp)
416 return (EPERM);
417 *oldlenp = sizeof(int);
418 if (oldp)
419 error = copyout((caddr_t)&val, oldp, sizeof(int));
420 return (error);
421 }
422
423 /*
424 * Validate parameters and get old / set new parameters
425 * for a string-valued sysctl function.
426 */
427 sysctl_string(oldp, oldlenp, newp, newlen, str, maxlen)
428 void *oldp;
429 size_t *oldlenp;
430 void *newp;
431 size_t newlen;
432 char *str;
433 int maxlen;
434 {
435 int len, error = 0;
436
437 len = strlen(str) + 1;
438 if (oldp && *oldlenp < len)
439 return (ENOMEM);
440 if (newp && newlen >= maxlen)
441 return (EINVAL);
442 if (oldp) {
443 *oldlenp = len;
444 error = copyout(str, oldp, len);
445 }
446 if (error == 0 && newp) {
447 error = copyin(newp, str, newlen);
448 str[newlen] = 0;
449 }
450 return (error);
451 }
452
453 /*
454 * As above, but read-only.
455 */
456 sysctl_rdstring(oldp, oldlenp, newp, str)
457 void *oldp;
458 size_t *oldlenp;
459 void *newp;
460 char *str;
461 {
462 int len, error = 0;
463
464 len = strlen(str) + 1;
465 if (oldp && *oldlenp < len)
466 return (ENOMEM);
467 if (newp)
468 return (EPERM);
469 *oldlenp = len;
470 if (oldp)
471 error = copyout(str, oldp, len);
472 return (error);
473 }
474
475 /*
476 * Validate parameters and get old / set new parameters
477 * for a structure oriented sysctl function.
478 */
479 sysctl_struct(oldp, oldlenp, newp, newlen, sp, len)
480 void *oldp;
481 size_t *oldlenp;
482 void *newp;
483 size_t newlen;
484 void *sp;
485 int len;
486 {
487 int error = 0;
488
489 if (oldp && *oldlenp < len)
490 return (ENOMEM);
491 if (newp && newlen > len)
492 return (EINVAL);
493 if (oldp) {
494 *oldlenp = len;
495 error = copyout(sp, oldp, len);
496 }
497 if (error == 0 && newp)
498 error = copyin(newp, sp, len);
499 return (error);
500 }
501
502 /*
503 * Validate parameters and get old parameters
504 * for a structure oriented sysctl function.
505 */
506 sysctl_rdstruct(oldp, oldlenp, newp, sp, len)
507 void *oldp;
508 size_t *oldlenp;
509 void *newp, *sp;
510 int len;
511 {
512 int error = 0;
513
514 if (oldp && *oldlenp < len)
515 return (ENOMEM);
516 if (newp)
517 return (EPERM);
518 *oldlenp = len;
519 if (oldp)
520 error = copyout(sp, oldp, len);
521 return (error);
522 }
523
524 /*
525 * Get file structures.
526 */
527 sysctl_file(where, sizep)
528 char *where;
529 size_t *sizep;
530 {
531 int buflen, error;
532 struct file *fp;
533 char *start = where;
534
535 buflen = *sizep;
536 if (where == NULL) {
537 /*
538 * overestimate by 10 files
539 */
540 *sizep = sizeof(filehead) + (nfiles + 10) * sizeof(struct file);
541 return (0);
542 }
543
544 /*
545 * first copyout filehead
546 */
547 if (buflen < sizeof(filehead)) {
548 *sizep = 0;
549 return (0);
550 }
551 if (error = copyout((caddr_t)&filehead, where, sizeof(filehead)))
552 return (error);
553 buflen -= sizeof(filehead);
554 where += sizeof(filehead);
555
556 /*
557 * followed by an array of file structures
558 */
559 for (fp = filehead.lh_first; fp != 0; fp = fp->f_list.le_next) {
560 if (buflen < sizeof(struct file)) {
561 *sizep = where - start;
562 return (ENOMEM);
563 }
564 if (error = copyout((caddr_t)fp, where, sizeof (struct file)))
565 return (error);
566 buflen -= sizeof(struct file);
567 where += sizeof(struct file);
568 }
569 *sizep = where - start;
570 return (0);
571 }
572
573 /*
574 * try over estimating by 5 procs
575 */
576 #define KERN_PROCSLOP (5 * sizeof (struct kinfo_proc))
577
578 sysctl_doproc(name, namelen, where, sizep)
579 int *name;
580 u_int namelen;
581 char *where;
582 size_t *sizep;
583 {
584 register struct proc *p;
585 register struct kinfo_proc *dp = (struct kinfo_proc *)where;
586 register int needed = 0;
587 int buflen = where != NULL ? *sizep : 0;
588 int doingzomb;
589 struct eproc eproc;
590 int error = 0;
591
592 if (namelen != 2 && !(namelen == 1 && name[0] == KERN_PROC_ALL))
593 return (EINVAL);
594 p = allproc.lh_first;
595 doingzomb = 0;
596 again:
597 for (; p != 0; p = p->p_list.le_next) {
598 /*
599 * Skip embryonic processes.
600 */
601 if (p->p_stat == SIDL)
602 continue;
603 /*
604 * TODO - make more efficient (see notes below).
605 * do by session.
606 */
607 switch (name[0]) {
608
609 case KERN_PROC_PID:
610 /* could do this with just a lookup */
611 if (p->p_pid != (pid_t)name[1])
612 continue;
613 break;
614
615 case KERN_PROC_PGRP:
616 /* could do this by traversing pgrp */
617 if (p->p_pgrp->pg_id != (pid_t)name[1])
618 continue;
619 break;
620
621 case KERN_PROC_TTY:
622 if ((p->p_flag & P_CONTROLT) == 0 ||
623 p->p_session->s_ttyp == NULL ||
624 p->p_session->s_ttyp->t_dev != (dev_t)name[1])
625 continue;
626 break;
627
628 case KERN_PROC_UID:
629 if (p->p_ucred->cr_uid != (uid_t)name[1])
630 continue;
631 break;
632
633 case KERN_PROC_RUID:
634 if (p->p_cred->p_ruid != (uid_t)name[1])
635 continue;
636 break;
637 }
638 if (buflen >= sizeof(struct kinfo_proc)) {
639 fill_eproc(p, &eproc);
640 if (error = copyout((caddr_t)p, &dp->kp_proc,
641 sizeof(struct proc)))
642 return (error);
643 if (error = copyout((caddr_t)&eproc, &dp->kp_eproc,
644 sizeof(eproc)))
645 return (error);
646 dp++;
647 buflen -= sizeof(struct kinfo_proc);
648 }
649 needed += sizeof(struct kinfo_proc);
650 }
651 if (doingzomb == 0) {
652 p = zombproc.lh_first;
653 doingzomb++;
654 goto again;
655 }
656 if (where != NULL) {
657 *sizep = (caddr_t)dp - where;
658 if (needed > *sizep)
659 return (ENOMEM);
660 } else {
661 needed += KERN_PROCSLOP;
662 *sizep = needed;
663 }
664 return (0);
665 }
666
667 /*
668 * Fill in an eproc structure for the specified process.
669 */
670 void
671 fill_eproc(p, ep)
672 register struct proc *p;
673 register struct eproc *ep;
674 {
675 register struct tty *tp;
676
677 ep->e_paddr = p;
678 ep->e_sess = p->p_pgrp->pg_session;
679 ep->e_pcred = *p->p_cred;
680 ep->e_ucred = *p->p_ucred;
681 if (p->p_stat == SIDL || p->p_stat == SZOMB) {
682 ep->e_vm.vm_rssize = 0;
683 ep->e_vm.vm_tsize = 0;
684 ep->e_vm.vm_dsize = 0;
685 ep->e_vm.vm_ssize = 0;
686 /* ep->e_vm.vm_pmap = XXX; */
687 } else {
688 register struct vmspace *vm = p->p_vmspace;
689
690 #ifdef pmap_resident_count
691 ep->e_vm.vm_rssize = pmap_resident_count(&vm->vm_pmap); /*XXX*/
692 #else
693 ep->e_vm.vm_rssize = vm->vm_rssize;
694 #endif
695 ep->e_vm.vm_tsize = vm->vm_tsize;
696 ep->e_vm.vm_dsize = vm->vm_dsize;
697 ep->e_vm.vm_ssize = vm->vm_ssize;
698 ep->e_vm.vm_pmap = vm->vm_pmap;
699 }
700 if (p->p_pptr)
701 ep->e_ppid = p->p_pptr->p_pid;
702 else
703 ep->e_ppid = 0;
704 ep->e_pgid = p->p_pgrp->pg_id;
705 ep->e_jobc = p->p_pgrp->pg_jobc;
706 if ((p->p_flag & P_CONTROLT) &&
707 (tp = ep->e_sess->s_ttyp)) {
708 ep->e_tdev = tp->t_dev;
709 ep->e_tpgid = tp->t_pgrp ? tp->t_pgrp->pg_id : NO_PID;
710 ep->e_tsess = tp->t_session;
711 } else
712 ep->e_tdev = NODEV;
713 ep->e_flag = ep->e_sess->s_ttyvp ? EPROC_CTTY : 0;
714 if (SESS_LEADER(p))
715 ep->e_flag |= EPROC_SLEADER;
716 if (p->p_wmesg)
717 strncpy(ep->e_wmesg, p->p_wmesg, WMESGLEN);
718 ep->e_xsize = ep->e_xrssize = 0;
719 ep->e_xccount = ep->e_xswrss = 0;
720 }
721
722