xref: /dragonfly/sys/kern/kern_proc.c (revision 9bb2a92d)
1 /*
2  * Copyright (c) 1982, 1986, 1989, 1991, 1993
3  *	The Regents of the University of California.  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
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. All advertising materials mentioning features or use of this software
14  *    must display the following acknowledgement:
15  *	This product includes software developed by the University of
16  *	California, Berkeley and its contributors.
17  * 4. Neither the name of the University nor the names of its contributors
18  *    may be used to endorse or promote products derived from this software
19  *    without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  *
33  *	@(#)kern_proc.c	8.7 (Berkeley) 2/14/95
34  * $FreeBSD: src/sys/kern/kern_proc.c,v 1.63.2.9 2003/05/08 07:47:16 kbyanc Exp $
35  * $DragonFly: src/sys/kern/kern_proc.c,v 1.13 2003/09/01 01:14:55 hmp Exp $
36  */
37 
38 #include <sys/param.h>
39 #include <sys/systm.h>
40 #include <sys/kernel.h>
41 #include <sys/sysctl.h>
42 #include <sys/malloc.h>
43 #include <sys/proc.h>
44 #include <sys/filedesc.h>
45 #include <sys/tty.h>
46 #include <sys/signalvar.h>
47 #include <vm/vm.h>
48 #include <sys/lock.h>
49 #include <vm/pmap.h>
50 #include <vm/vm_map.h>
51 #include <sys/user.h>
52 #include <vm/vm_zone.h>
53 
54 static MALLOC_DEFINE(M_PGRP, "pgrp", "process group header");
55 MALLOC_DEFINE(M_SESSION, "session", "session header");
56 static MALLOC_DEFINE(M_PROC, "proc", "Proc structures");
57 MALLOC_DEFINE(M_SUBPROC, "subproc", "Proc sub-structures");
58 
59 int ps_showallprocs = 1;
60 static int ps_showallthreads = 1;
61 SYSCTL_INT(_kern, OID_AUTO, ps_showallprocs, CTLFLAG_RW,
62     &ps_showallprocs, 0, "");
63 SYSCTL_INT(_kern, OID_AUTO, ps_showallthreads, CTLFLAG_RW,
64     &ps_showallthreads, 0, "");
65 
66 static void pgdelete	(struct pgrp *);
67 
68 static void	orphanpg (struct pgrp *pg);
69 
70 /*
71  * Other process lists
72  */
73 struct pidhashhead *pidhashtbl;
74 u_long pidhash;
75 struct pgrphashhead *pgrphashtbl;
76 u_long pgrphash;
77 struct proclist allproc;
78 struct proclist zombproc;
79 vm_zone_t proc_zone;
80 vm_zone_t thread_zone;
81 
82 /*
83  * Initialize global process hashing structures.
84  */
85 void
86 procinit()
87 {
88 
89 	LIST_INIT(&allproc);
90 	LIST_INIT(&zombproc);
91 	pidhashtbl = hashinit(maxproc / 4, M_PROC, &pidhash);
92 	pgrphashtbl = hashinit(maxproc / 4, M_PROC, &pgrphash);
93 	proc_zone = zinit("PROC", sizeof (struct proc), 0, 0, 5);
94 	thread_zone = zinit("THREAD", sizeof (struct thread), 0, 0, 5);
95 	uihashinit();
96 }
97 
98 /*
99  * Is p an inferior of the current process?
100  */
101 int
102 inferior(p)
103 	struct proc *p;
104 {
105 
106 	for (; p != curproc; p = p->p_pptr)
107 		if (p->p_pid == 0)
108 			return (0);
109 	return (1);
110 }
111 
112 /*
113  * Locate a process by number
114  */
115 struct proc *
116 pfind(pid)
117 	pid_t pid;
118 {
119 	struct proc *p;
120 
121 	LIST_FOREACH(p, PIDHASH(pid), p_hash)
122 		if (p->p_pid == pid)
123 			return (p);
124 	return (NULL);
125 }
126 
127 /*
128  * Locate a process group by number
129  */
130 struct pgrp *
131 pgfind(pgid)
132 	pid_t pgid;
133 {
134 	struct pgrp *pgrp;
135 
136 	LIST_FOREACH(pgrp, PGRPHASH(pgid), pg_hash)
137 		if (pgrp->pg_id == pgid)
138 			return (pgrp);
139 	return (NULL);
140 }
141 
142 /*
143  * Move p to a new or existing process group (and session)
144  */
145 int
146 enterpgrp(p, pgid, mksess)
147 	struct proc *p;
148 	pid_t pgid;
149 	int mksess;
150 {
151 	struct pgrp *pgrp = pgfind(pgid);
152 
153 	KASSERT(pgrp == NULL || !mksess,
154 	    ("enterpgrp: setsid into non-empty pgrp"));
155 	KASSERT(!SESS_LEADER(p),
156 	    ("enterpgrp: session leader attempted setpgrp"));
157 
158 	if (pgrp == NULL) {
159 		pid_t savepid = p->p_pid;
160 		struct proc *np;
161 		/*
162 		 * new process group
163 		 */
164 		KASSERT(p->p_pid == pgid,
165 		    ("enterpgrp: new pgrp and pid != pgid"));
166 		if ((np = pfind(savepid)) == NULL || np != p)
167 			return (ESRCH);
168 		MALLOC(pgrp, struct pgrp *, sizeof(struct pgrp), M_PGRP,
169 		    M_WAITOK);
170 		if (mksess) {
171 			struct session *sess;
172 
173 			/*
174 			 * new session
175 			 */
176 			MALLOC(sess, struct session *, sizeof(struct session),
177 			    M_SESSION, M_WAITOK);
178 			sess->s_leader = p;
179 			sess->s_sid = p->p_pid;
180 			sess->s_count = 1;
181 			sess->s_ttyvp = NULL;
182 			sess->s_ttyp = NULL;
183 			bcopy(p->p_session->s_login, sess->s_login,
184 			    sizeof(sess->s_login));
185 			p->p_flag &= ~P_CONTROLT;
186 			pgrp->pg_session = sess;
187 			KASSERT(p == curproc,
188 			    ("enterpgrp: mksession and p != curproc"));
189 		} else {
190 			pgrp->pg_session = p->p_session;
191 			pgrp->pg_session->s_count++;
192 		}
193 		pgrp->pg_id = pgid;
194 		LIST_INIT(&pgrp->pg_members);
195 		LIST_INSERT_HEAD(PGRPHASH(pgid), pgrp, pg_hash);
196 		pgrp->pg_jobc = 0;
197 		SLIST_INIT(&pgrp->pg_sigiolst);
198 	} else if (pgrp == p->p_pgrp)
199 		return (0);
200 
201 	/*
202 	 * Adjust eligibility of affected pgrps to participate in job control.
203 	 * Increment eligibility counts before decrementing, otherwise we
204 	 * could reach 0 spuriously during the first call.
205 	 */
206 	fixjobc(p, pgrp, 1);
207 	fixjobc(p, p->p_pgrp, 0);
208 
209 	LIST_REMOVE(p, p_pglist);
210 	if (LIST_EMPTY(&p->p_pgrp->pg_members))
211 		pgdelete(p->p_pgrp);
212 	p->p_pgrp = pgrp;
213 	LIST_INSERT_HEAD(&pgrp->pg_members, p, p_pglist);
214 	return (0);
215 }
216 
217 /*
218  * remove process from process group
219  */
220 int
221 leavepgrp(p)
222 	struct proc *p;
223 {
224 
225 	LIST_REMOVE(p, p_pglist);
226 	if (LIST_EMPTY(&p->p_pgrp->pg_members))
227 		pgdelete(p->p_pgrp);
228 	p->p_pgrp = 0;
229 	return (0);
230 }
231 
232 /*
233  * delete a process group
234  */
235 static void
236 pgdelete(pgrp)
237 	struct pgrp *pgrp;
238 {
239 
240 	/*
241 	 * Reset any sigio structures pointing to us as a result of
242 	 * F_SETOWN with our pgid.
243 	 */
244 	funsetownlst(&pgrp->pg_sigiolst);
245 
246 	if (pgrp->pg_session->s_ttyp != NULL &&
247 	    pgrp->pg_session->s_ttyp->t_pgrp == pgrp)
248 		pgrp->pg_session->s_ttyp->t_pgrp = NULL;
249 	LIST_REMOVE(pgrp, pg_hash);
250 	if (--pgrp->pg_session->s_count == 0)
251 		FREE(pgrp->pg_session, M_SESSION);
252 	FREE(pgrp, M_PGRP);
253 }
254 
255 /*
256  * Adjust pgrp jobc counters when specified process changes process group.
257  * We count the number of processes in each process group that "qualify"
258  * the group for terminal job control (those with a parent in a different
259  * process group of the same session).  If that count reaches zero, the
260  * process group becomes orphaned.  Check both the specified process'
261  * process group and that of its children.
262  * entering == 0 => p is leaving specified group.
263  * entering == 1 => p is entering specified group.
264  */
265 void
266 fixjobc(p, pgrp, entering)
267 	struct proc *p;
268 	struct pgrp *pgrp;
269 	int entering;
270 {
271 	struct pgrp *hispgrp;
272 	struct session *mysession = pgrp->pg_session;
273 
274 	/*
275 	 * Check p's parent to see whether p qualifies its own process
276 	 * group; if so, adjust count for p's process group.
277 	 */
278 	if ((hispgrp = p->p_pptr->p_pgrp) != pgrp &&
279 	    hispgrp->pg_session == mysession) {
280 		if (entering)
281 			pgrp->pg_jobc++;
282 		else if (--pgrp->pg_jobc == 0)
283 			orphanpg(pgrp);
284 	}
285 
286 	/*
287 	 * Check this process' children to see whether they qualify
288 	 * their process groups; if so, adjust counts for children's
289 	 * process groups.
290 	 */
291 	LIST_FOREACH(p, &p->p_children, p_sibling)
292 		if ((hispgrp = p->p_pgrp) != pgrp &&
293 		    hispgrp->pg_session == mysession &&
294 		    p->p_stat != SZOMB) {
295 			if (entering)
296 				hispgrp->pg_jobc++;
297 			else if (--hispgrp->pg_jobc == 0)
298 				orphanpg(hispgrp);
299 		}
300 }
301 
302 /*
303  * A process group has become orphaned;
304  * if there are any stopped processes in the group,
305  * hang-up all process in that group.
306  */
307 static void
308 orphanpg(pg)
309 	struct pgrp *pg;
310 {
311 	struct proc *p;
312 
313 	LIST_FOREACH(p, &pg->pg_members, p_pglist) {
314 		if (p->p_stat == SSTOP) {
315 			LIST_FOREACH(p, &pg->pg_members, p_pglist) {
316 				psignal(p, SIGHUP);
317 				psignal(p, SIGCONT);
318 			}
319 			return;
320 		}
321 	}
322 }
323 
324 #include "opt_ddb.h"
325 #ifdef DDB
326 #include <ddb/ddb.h>
327 
328 DB_SHOW_COMMAND(pgrpdump, pgrpdump)
329 {
330 	struct pgrp *pgrp;
331 	struct proc *p;
332 	int i;
333 
334 	for (i = 0; i <= pgrphash; i++) {
335 		if (!LIST_EMPTY(&pgrphashtbl[i])) {
336 			printf("\tindx %d\n", i);
337 			LIST_FOREACH(pgrp, &pgrphashtbl[i], pg_hash) {
338 				printf(
339 			"\tpgrp %p, pgid %ld, sess %p, sesscnt %d, mem %p\n",
340 				    (void *)pgrp, (long)pgrp->pg_id,
341 				    (void *)pgrp->pg_session,
342 				    pgrp->pg_session->s_count,
343 				    (void *)LIST_FIRST(&pgrp->pg_members));
344 				LIST_FOREACH(p, &pgrp->pg_members, p_pglist) {
345 					printf("\t\tpid %ld addr %p pgrp %p\n",
346 					    (long)p->p_pid, (void *)p,
347 					    (void *)p->p_pgrp);
348 				}
349 			}
350 		}
351 	}
352 }
353 #endif /* DDB */
354 
355 /*
356  * Fill in an eproc structure for the specified thread.
357  */
358 void
359 fill_eproc_td(thread_t td, struct eproc *ep, struct proc *xp)
360 {
361 	bzero(ep, sizeof(*ep));
362 
363 	ep->e_uticks = td->td_uticks;
364 	ep->e_sticks = td->td_sticks;
365 	ep->e_iticks = td->td_iticks;
366 	ep->e_tdev = NOUDEV;
367 	ep->e_cpuid = td->td_gd->gd_cpuid;
368 	if (td->td_wmesg) {
369 		strncpy(ep->e_wmesg, td->td_wmesg, WMESGLEN);
370 		ep->e_wmesg[WMESGLEN] = 0;
371 	}
372 
373 	/*
374 	 * Fake up portions of the proc structure copied out by the sysctl
375 	 * to return useful information.  Note that using td_pri directly
376 	 * is messy because it includes critial section data so we fake
377 	 * up an rtprio.prio for threads.
378 	 */
379 	if (xp) {
380 		*xp = *initproc;
381 		xp->p_rtprio.type = RTP_PRIO_THREAD;
382 		xp->p_rtprio.prio = td->td_pri & TDPRI_MASK;
383 		xp->p_pid = -1;
384 	}
385 }
386 
387 /*
388  * Fill in an eproc structure for the specified process.
389  */
390 void
391 fill_eproc(struct proc *p, struct eproc *ep)
392 {
393 	struct tty *tp;
394 
395 	fill_eproc_td(p->p_thread, ep, NULL);
396 
397 	ep->e_paddr = p;
398 	if (p->p_ucred) {
399 		ep->e_ucred = *p->p_ucred;
400 	}
401 	if (p->p_procsig) {
402 		ep->e_procsig = *p->p_procsig;
403 	}
404 	if (p->p_stat != SIDL && p->p_stat != SZOMB && p->p_vmspace != NULL) {
405 		struct vmspace *vm = p->p_vmspace;
406 		ep->e_vm = *vm;
407 		ep->e_vm.vm_rssize = vmspace_resident_count(vm); /*XXX*/
408 	}
409 	if ((p->p_flag & P_INMEM) && p->p_stats)
410 		ep->e_stats = *p->p_stats;
411 	if (p->p_pptr)
412 		ep->e_ppid = p->p_pptr->p_pid;
413 	if (p->p_pgrp) {
414 		ep->e_pgid = p->p_pgrp->pg_id;
415 		ep->e_jobc = p->p_pgrp->pg_jobc;
416 		ep->e_sess = p->p_pgrp->pg_session;
417 
418 		if (ep->e_sess) {
419 			bcopy(ep->e_sess->s_login, ep->e_login, sizeof(ep->e_login));
420 			if (ep->e_sess->s_ttyvp)
421 				ep->e_flag = EPROC_CTTY;
422 			if (p->p_session && SESS_LEADER(p))
423 				ep->e_flag |= EPROC_SLEADER;
424 		}
425 	}
426 	if ((p->p_flag & P_CONTROLT) &&
427 	    (ep->e_sess != NULL) &&
428 	    ((tp = ep->e_sess->s_ttyp) != NULL)) {
429 		ep->e_tdev = dev2udev(tp->t_dev);
430 		ep->e_tpgid = tp->t_pgrp ? tp->t_pgrp->pg_id : NO_PID;
431 		ep->e_tsess = tp->t_session;
432 	} else {
433 		ep->e_tdev = NOUDEV;
434 	}
435 }
436 
437 struct proc *
438 zpfind(pid_t pid)
439 {
440 	struct proc *p;
441 
442 	LIST_FOREACH(p, &zombproc, p_list)
443 		if (p->p_pid == pid)
444 			return (p);
445 	return (NULL);
446 }
447 
448 static int
449 sysctl_out_proc(struct proc *p, struct thread *td, struct sysctl_req *req, int doingzomb)
450 {
451 	struct eproc eproc;
452 	struct proc xproc;
453 	int error;
454 #if 0
455 	pid_t pid = p->p_pid;
456 #endif
457 
458 	if (p) {
459 		td = p->p_thread;
460 		fill_eproc(p, &eproc);
461 		xproc = *p;
462 	} else if (td) {
463 		fill_eproc_td(td, &eproc, &xproc);
464 	}
465 	error = SYSCTL_OUT(req,(caddr_t)&xproc, sizeof(struct proc));
466 	if (error)
467 		return (error);
468 	error = SYSCTL_OUT(req,(caddr_t)&eproc, sizeof(eproc));
469 	if (error)
470 		return (error);
471 	error = SYSCTL_OUT(req,(caddr_t)td, sizeof(struct thread));
472 	if (error)
473 		return (error);
474 #if 0
475 	if (!doingzomb && pid && (pfind(pid) != p))
476 		return EAGAIN;
477 	if (doingzomb && zpfind(pid) != p)
478 		return EAGAIN;
479 #endif
480 	return (0);
481 }
482 
483 static int
484 sysctl_kern_proc(SYSCTL_HANDLER_ARGS)
485 {
486 	int *name = (int*) arg1;
487 	u_int namelen = arg2;
488 	struct proc *p;
489 	struct thread *td;
490 	int doingzomb;
491 	int error = 0;
492 	struct ucred *cr1 = curproc->p_ucred;
493 
494 	if (oidp->oid_number == KERN_PROC_PID) {
495 		if (namelen != 1)
496 			return (EINVAL);
497 		p = pfind((pid_t)name[0]);
498 		if (!p)
499 			return (0);
500 		if (!PRISON_CHECK(cr1, p->p_ucred))
501 			return (0);
502 		error = sysctl_out_proc(p, NULL, req, 0);
503 		return (error);
504 	}
505 	if (oidp->oid_number == KERN_PROC_ALL && !namelen)
506 		;
507 	else if (oidp->oid_number != KERN_PROC_ALL && namelen == 1)
508 		;
509 	else
510 		return (EINVAL);
511 
512 	if (!req->oldptr) {
513 		/* overestimate by 5 procs */
514 		error = SYSCTL_OUT(req, 0, sizeof (struct kinfo_proc) * 5);
515 		if (error)
516 			return (error);
517 	}
518 	for (doingzomb=0 ; doingzomb < 2 ; doingzomb++) {
519 		if (!doingzomb)
520 			p = LIST_FIRST(&allproc);
521 		else
522 			p = LIST_FIRST(&zombproc);
523 		for (; p != 0; p = LIST_NEXT(p, p_list)) {
524 			/*
525 			 * Show a user only their processes.
526 			 */
527 			if ((!ps_showallprocs) && p_trespass(cr1, p->p_ucred))
528 				continue;
529 			/*
530 			 * Skip embryonic processes.
531 			 */
532 			if (p->p_stat == SIDL)
533 				continue;
534 			/*
535 			 * TODO - make more efficient (see notes below).
536 			 * do by session.
537 			 */
538 			switch (oidp->oid_number) {
539 			case KERN_PROC_PGRP:
540 				/* could do this by traversing pgrp */
541 				if (p->p_pgrp == NULL ||
542 				    p->p_pgrp->pg_id != (pid_t)name[0])
543 					continue;
544 				break;
545 
546 			case KERN_PROC_TTY:
547 				if ((p->p_flag & P_CONTROLT) == 0 ||
548 				    p->p_session == NULL ||
549 				    p->p_session->s_ttyp == NULL ||
550 				    dev2udev(p->p_session->s_ttyp->t_dev) !=
551 					(udev_t)name[0])
552 					continue;
553 				break;
554 
555 			case KERN_PROC_UID:
556 				if (p->p_ucred == NULL ||
557 				    p->p_ucred->cr_uid != (uid_t)name[0])
558 					continue;
559 				break;
560 
561 			case KERN_PROC_RUID:
562 				if (p->p_ucred == NULL ||
563 				    p->p_ucred->cr_ruid != (uid_t)name[0])
564 					continue;
565 				break;
566 			}
567 
568 			if (!PRISON_CHECK(cr1, p->p_ucred))
569 				continue;
570 			PHOLD(p);
571 			error = sysctl_out_proc(p, NULL, req, doingzomb);
572 			PRELE(p);
573 			if (error)
574 				return (error);
575 		}
576 	}
577 	if (ps_showallthreads) {
578 		TAILQ_FOREACH(td, &mycpu->gd_tdallq, td_allq) {
579 			if (td->td_proc)
580 				continue;
581 			switch (oidp->oid_number) {
582 			case KERN_PROC_PGRP:
583 			case KERN_PROC_TTY:
584 			case KERN_PROC_UID:
585 			case KERN_PROC_RUID:
586 				continue;
587 			default:
588 				break;
589 			}
590 			lwkt_hold(td);
591 			error = sysctl_out_proc(NULL, td, req, doingzomb);
592 			lwkt_rele(td);
593 			if (error)
594 				return (error);
595 		}
596 	}
597 	return (0);
598 }
599 
600 /*
601  * This sysctl allows a process to retrieve the argument list or process
602  * title for another process without groping around in the address space
603  * of the other process.  It also allow a process to set its own "process
604  * title to a string of its own choice.
605  */
606 static int
607 sysctl_kern_proc_args(SYSCTL_HANDLER_ARGS)
608 {
609 	int *name = (int*) arg1;
610 	u_int namelen = arg2;
611 	struct proc *p;
612 	struct pargs *pa;
613 	int error = 0;
614 	struct ucred *cr1 = curproc->p_ucred;
615 
616 	if (namelen != 1)
617 		return (EINVAL);
618 
619 	p = pfind((pid_t)name[0]);
620 	if (!p)
621 		return (0);
622 
623 	if ((!ps_argsopen) && p_trespass(cr1, p->p_ucred))
624 		return (0);
625 
626 	if (req->newptr && curproc != p)
627 		return (EPERM);
628 
629 	if (req->oldptr && p->p_args != NULL)
630 		error = SYSCTL_OUT(req, p->p_args->ar_args, p->p_args->ar_length);
631 	if (req->newptr == NULL)
632 		return (error);
633 
634 	if (p->p_args && --p->p_args->ar_ref == 0)
635 		FREE(p->p_args, M_PARGS);
636 	p->p_args = NULL;
637 
638 	if (req->newlen + sizeof(struct pargs) > ps_arg_cache_limit)
639 		return (error);
640 
641 	MALLOC(pa, struct pargs *, sizeof(struct pargs) + req->newlen,
642 	    M_PARGS, M_WAITOK);
643 	pa->ar_ref = 1;
644 	pa->ar_length = req->newlen;
645 	error = SYSCTL_IN(req, pa->ar_args, req->newlen);
646 	if (!error)
647 		p->p_args = pa;
648 	else
649 		FREE(pa, M_PARGS);
650 	return (error);
651 }
652 
653 SYSCTL_NODE(_kern, KERN_PROC, proc, CTLFLAG_RD,  0, "Process table");
654 
655 SYSCTL_PROC(_kern_proc, KERN_PROC_ALL, all, CTLFLAG_RD|CTLTYPE_STRUCT,
656 	0, 0, sysctl_kern_proc, "S,proc", "Return entire process table");
657 
658 SYSCTL_NODE(_kern_proc, KERN_PROC_PGRP, pgrp, CTLFLAG_RD,
659 	sysctl_kern_proc, "Process table");
660 
661 SYSCTL_NODE(_kern_proc, KERN_PROC_TTY, tty, CTLFLAG_RD,
662 	sysctl_kern_proc, "Process table");
663 
664 SYSCTL_NODE(_kern_proc, KERN_PROC_UID, uid, CTLFLAG_RD,
665 	sysctl_kern_proc, "Process table");
666 
667 SYSCTL_NODE(_kern_proc, KERN_PROC_RUID, ruid, CTLFLAG_RD,
668 	sysctl_kern_proc, "Process table");
669 
670 SYSCTL_NODE(_kern_proc, KERN_PROC_PID, pid, CTLFLAG_RD,
671 	sysctl_kern_proc, "Process table");
672 
673 SYSCTL_NODE(_kern_proc, KERN_PROC_ARGS, args, CTLFLAG_RW | CTLFLAG_ANYBODY,
674 	sysctl_kern_proc_args, "Process argument list");
675