2 * Copyright (c) 1982, 1986, 1989, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
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
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.32 2007/02/01 10:33:25 corecode Exp $
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>
45 #include <sys/filedesc.h>
47 #include <sys/signalvar.h>
48 #include <sys/spinlock.h>
52 #include <vm/vm_map.h>
54 #include <vm/vm_zone.h>
55 #include <machine/smp.h>
57 #include <sys/spinlock2.h>
59 static MALLOC_DEFINE(M_PGRP, "pgrp", "process group header");
60 MALLOC_DEFINE(M_SESSION, "session", "session header");
61 static MALLOC_DEFINE(M_PROC, "proc", "Proc structures");
62 MALLOC_DEFINE(M_SUBPROC, "subproc", "Proc sub-structures");
64 int ps_showallprocs = 1;
65 static int ps_showallthreads = 1;
66 SYSCTL_INT(_kern, OID_AUTO, ps_showallprocs, CTLFLAG_RW,
67 &ps_showallprocs, 0, "");
68 SYSCTL_INT(_kern, OID_AUTO, ps_showallthreads, CTLFLAG_RW,
69 &ps_showallthreads, 0, "");
71 static void pgdelete(struct pgrp *);
72 static void orphanpg(struct pgrp *pg);
73 static pid_t proc_getnewpid_locked(int random_offset);
78 struct pidhashhead *pidhashtbl;
80 struct pgrphashhead *pgrphashtbl;
82 struct proclist allproc;
83 struct proclist zombproc;
84 struct spinlock allproc_spin;
86 vm_zone_t thread_zone;
89 * Random component to nextpid generation. We mix in a random factor to make
90 * it a little harder to predict. We sanity check the modulus value to avoid
91 * doing it in critical paths. Don't let it be too small or we pointlessly
92 * waste randomness entropy, and don't let it be impossibly large. Using a
93 * modulus that is too big causes a LOT more process table scans and slows
94 * down fork processing as the pidchecked caching is defeated.
96 static int randompid = 0;
99 sysctl_kern_randompid(SYSCTL_HANDLER_ARGS)
104 error = sysctl_handle_int(oidp, &pid, 0, req);
105 if (error || !req->newptr)
107 if (pid < 0 || pid > PID_MAX - 100) /* out of range */
109 else if (pid < 2) /* NOP */
111 else if (pid < 100) /* Make it reasonable */
117 SYSCTL_PROC(_kern, OID_AUTO, randompid, CTLTYPE_INT|CTLFLAG_RW,
118 0, 0, sysctl_kern_randompid, "I", "Random PID modulus");
121 * Initialize global process hashing structures.
127 LIST_INIT(&zombproc);
128 spin_init(&allproc_spin);
129 pidhashtbl = hashinit(maxproc / 4, M_PROC, &pidhash);
130 pgrphashtbl = hashinit(maxproc / 4, M_PROC, &pgrphash);
131 proc_zone = zinit("PROC", sizeof (struct proc), 0, 0, 5);
132 thread_zone = zinit("THREAD", sizeof (struct thread), 0, 0, 5);
137 * Is p an inferior of the current process?
140 inferior(struct proc *p)
142 for (; p != curproc; p = p->p_pptr)
149 * Locate a process by number
156 LIST_FOREACH(p, PIDHASH(pid), p_hash) {
164 * Locate a process group by number
171 LIST_FOREACH(pgrp, PGRPHASH(pgid), pg_hash) {
172 if (pgrp->pg_id == pgid)
179 * Move p to a new or existing process group (and session)
182 enterpgrp(struct proc *p, pid_t pgid, int mksess)
184 struct pgrp *pgrp = pgfind(pgid);
186 KASSERT(pgrp == NULL || !mksess,
187 ("enterpgrp: setsid into non-empty pgrp"));
188 KASSERT(!SESS_LEADER(p),
189 ("enterpgrp: session leader attempted setpgrp"));
192 pid_t savepid = p->p_pid;
197 KASSERT(p->p_pid == pgid,
198 ("enterpgrp: new pgrp and pid != pgid"));
199 if ((np = pfind(savepid)) == NULL || np != p)
201 MALLOC(pgrp, struct pgrp *, sizeof(struct pgrp), M_PGRP,
204 struct session *sess;
209 MALLOC(sess, struct session *, sizeof(struct session),
210 M_SESSION, M_WAITOK);
212 sess->s_sid = p->p_pid;
214 sess->s_ttyvp = NULL;
216 bcopy(p->p_session->s_login, sess->s_login,
217 sizeof(sess->s_login));
218 p->p_flag &= ~P_CONTROLT;
219 pgrp->pg_session = sess;
220 KASSERT(p == curproc,
221 ("enterpgrp: mksession and p != curproc"));
223 pgrp->pg_session = p->p_session;
224 sess_hold(pgrp->pg_session);
227 LIST_INIT(&pgrp->pg_members);
228 LIST_INSERT_HEAD(PGRPHASH(pgid), pgrp, pg_hash);
230 SLIST_INIT(&pgrp->pg_sigiolst);
231 lockinit(&pgrp->pg_lock, "pgwt", 0, 0);
232 } else if (pgrp == p->p_pgrp)
236 * Adjust eligibility of affected pgrps to participate in job control.
237 * Increment eligibility counts before decrementing, otherwise we
238 * could reach 0 spuriously during the first call.
241 fixjobc(p, p->p_pgrp, 0);
243 LIST_REMOVE(p, p_pglist);
244 if (LIST_EMPTY(&p->p_pgrp->pg_members))
247 LIST_INSERT_HEAD(&pgrp->pg_members, p, p_pglist);
252 * remove process from process group
255 leavepgrp(struct proc *p)
258 LIST_REMOVE(p, p_pglist);
259 if (LIST_EMPTY(&p->p_pgrp->pg_members))
266 * delete a process group
269 pgdelete(struct pgrp *pgrp)
273 * Reset any sigio structures pointing to us as a result of
274 * F_SETOWN with our pgid.
276 funsetownlst(&pgrp->pg_sigiolst);
278 if (pgrp->pg_session->s_ttyp != NULL &&
279 pgrp->pg_session->s_ttyp->t_pgrp == pgrp)
280 pgrp->pg_session->s_ttyp->t_pgrp = NULL;
281 LIST_REMOVE(pgrp, pg_hash);
282 sess_rele(pgrp->pg_session);
287 * Adjust the ref count on a session structure. When the ref count falls to
288 * zero the tty is disassociated from the session and the session structure
289 * is freed. Note that tty assocation is not itself ref-counted.
292 sess_hold(struct session *sp)
298 sess_rele(struct session *sp)
300 KKASSERT(sp->s_count > 0);
301 if (--sp->s_count == 0) {
302 if (sp->s_ttyp && sp->s_ttyp->t_session) {
303 #ifdef TTY_DO_FULL_CLOSE
304 /* FULL CLOSE, see ttyclearsession() */
305 KKASSERT(sp->s_ttyp->t_session == sp);
306 sp->s_ttyp->t_session = NULL;
308 /* HALF CLOSE, see ttyclearsession() */
309 if (sp->s_ttyp->t_session == sp)
310 sp->s_ttyp->t_session = NULL;
313 kfree(sp, M_SESSION);
318 * Adjust pgrp jobc counters when specified process changes process group.
319 * We count the number of processes in each process group that "qualify"
320 * the group for terminal job control (those with a parent in a different
321 * process group of the same session). If that count reaches zero, the
322 * process group becomes orphaned. Check both the specified process'
323 * process group and that of its children.
324 * entering == 0 => p is leaving specified group.
325 * entering == 1 => p is entering specified group.
328 fixjobc(struct proc *p, struct pgrp *pgrp, int entering)
330 struct pgrp *hispgrp;
331 struct session *mysession = pgrp->pg_session;
334 * Check p's parent to see whether p qualifies its own process
335 * group; if so, adjust count for p's process group.
337 if ((hispgrp = p->p_pptr->p_pgrp) != pgrp &&
338 hispgrp->pg_session == mysession) {
341 else if (--pgrp->pg_jobc == 0)
346 * Check this process' children to see whether they qualify
347 * their process groups; if so, adjust counts for children's
350 LIST_FOREACH(p, &p->p_children, p_sibling)
351 if ((hispgrp = p->p_pgrp) != pgrp &&
352 hispgrp->pg_session == mysession &&
353 (p->p_flag & P_ZOMBIE) == 0) {
356 else if (--hispgrp->pg_jobc == 0)
362 * A process group has become orphaned;
363 * if there are any stopped processes in the group,
364 * hang-up all process in that group.
367 orphanpg(struct pgrp *pg)
371 LIST_FOREACH(p, &pg->pg_members, p_pglist) {
372 if (p->p_flag & P_STOPPED) {
373 LIST_FOREACH(p, &pg->pg_members, p_pglist) {
383 * Add a new process to the allproc list and the PID hash. This
384 * also assigns a pid to the new process.
386 * MPALMOSTSAFE - acquires mplock for karc4random() call
389 proc_add_allproc(struct proc *p)
393 if ((random_offset = randompid) != 0) {
395 random_offset = karc4random() % random_offset;
399 spin_lock_wr(&allproc_spin);
400 p->p_pid = proc_getnewpid_locked(random_offset);
401 LIST_INSERT_HEAD(&allproc, p, p_list);
402 LIST_INSERT_HEAD(PIDHASH(p->p_pid), p, p_hash);
403 spin_unlock_wr(&allproc_spin);
407 * Calculate a new process pid. This function is integrated into
408 * proc_add_allproc() to guarentee that the new pid is not reused before
409 * the new process can be added to the allproc list.
411 * MPSAFE - must be called with allproc_spin held.
415 proc_getnewpid_locked(int random_offset)
417 static pid_t nextpid;
418 static pid_t pidchecked;
422 * Find an unused process ID. We remember a range of unused IDs
423 * ready to use (from nextpid+1 through pidchecked-1).
425 nextpid = nextpid + 1 + random_offset;
428 * If the process ID prototype has wrapped around,
429 * restart somewhat above 0, as the low-numbered procs
430 * tend to include daemons that don't exit.
432 if (nextpid >= PID_MAX) {
433 nextpid = nextpid % PID_MAX;
438 if (nextpid >= pidchecked) {
441 pidchecked = PID_MAX;
443 * Scan the active and zombie procs to check whether this pid
444 * is in use. Remember the lowest pid that's greater
445 * than nextpid, so we can avoid checking for a while.
447 p = LIST_FIRST(&allproc);
449 for (; p != 0; p = LIST_NEXT(p, p_list)) {
450 while (p->p_pid == nextpid ||
451 p->p_pgrp->pg_id == nextpid ||
452 p->p_session->s_sid == nextpid) {
454 if (nextpid >= pidchecked)
457 if (p->p_pid > nextpid && pidchecked > p->p_pid)
458 pidchecked = p->p_pid;
459 if (p->p_pgrp->pg_id > nextpid &&
460 pidchecked > p->p_pgrp->pg_id)
461 pidchecked = p->p_pgrp->pg_id;
462 if (p->p_session->s_sid > nextpid &&
463 pidchecked > p->p_session->s_sid)
464 pidchecked = p->p_session->s_sid;
468 p = LIST_FIRST(&zombproc);
476 * Called from exit1 to remove a process from the allproc
477 * list and move it to the zombie list.
482 proc_move_allproc_zombie(struct proc *p)
484 spin_lock_wr(&allproc_spin);
486 spin_unlock_wr(&allproc_spin);
487 tsleep(p, 0, "reap1", hz / 10);
488 spin_lock_wr(&allproc_spin);
490 LIST_REMOVE(p, p_list);
491 LIST_INSERT_HEAD(&zombproc, p, p_list);
492 LIST_REMOVE(p, p_hash);
493 p->p_flag |= P_ZOMBIE;
494 spin_unlock_wr(&allproc_spin);
498 * This routine is called from kern_wait() and will remove the process
499 * from the zombie list and the sibling list. This routine will block
500 * if someone has a lock on the proces (p_lock).
505 proc_remove_zombie(struct proc *p)
507 spin_lock_wr(&allproc_spin);
509 spin_unlock_wr(&allproc_spin);
510 tsleep(p, 0, "reap1", hz / 10);
511 spin_lock_wr(&allproc_spin);
513 LIST_REMOVE(p, p_list); /* off zombproc */
514 LIST_REMOVE(p, p_sibling);
515 spin_unlock_wr(&allproc_spin);
519 * Scan all processes on the allproc list. The process is automatically
520 * held for the callback. A return value of -1 terminates the loop.
525 allproc_scan(int (*callback)(struct proc *, void *), void *data)
530 spin_lock_rd(&allproc_spin);
531 LIST_FOREACH(p, &allproc, p_list) {
533 spin_unlock_rd(&allproc_spin);
534 r = callback(p, data);
535 spin_lock_rd(&allproc_spin);
540 spin_unlock_rd(&allproc_spin);
544 * Scan all processes on the zombproc list. The process is automatically
545 * held for the callback. A return value of -1 terminates the loop.
550 zombproc_scan(int (*callback)(struct proc *, void *), void *data)
555 spin_lock_rd(&allproc_spin);
556 LIST_FOREACH(p, &zombproc, p_list) {
558 spin_unlock_rd(&allproc_spin);
559 r = callback(p, data);
560 spin_lock_rd(&allproc_spin);
565 spin_unlock_rd(&allproc_spin);
572 DB_SHOW_COMMAND(pgrpdump, pgrpdump)
578 for (i = 0; i <= pgrphash; i++) {
579 if (!LIST_EMPTY(&pgrphashtbl[i])) {
580 kprintf("\tindx %d\n", i);
581 LIST_FOREACH(pgrp, &pgrphashtbl[i], pg_hash) {
583 "\tpgrp %p, pgid %ld, sess %p, sesscnt %d, mem %p\n",
584 (void *)pgrp, (long)pgrp->pg_id,
585 (void *)pgrp->pg_session,
586 pgrp->pg_session->s_count,
587 (void *)LIST_FIRST(&pgrp->pg_members));
588 LIST_FOREACH(p, &pgrp->pg_members, p_pglist) {
589 kprintf("\t\tpid %ld addr %p pgrp %p\n",
590 (long)p->p_pid, (void *)p,
601 * Fill in an eproc structure for the specified thread.
604 fill_eproc_td(thread_t td, struct eproc *ep, struct proc *xp)
606 bzero(ep, sizeof(*ep));
608 ep->e_uticks = td->td_uticks;
609 ep->e_sticks = td->td_sticks;
610 ep->e_iticks = td->td_iticks;
612 ep->e_cpuid = td->td_gd->gd_cpuid;
614 strncpy(ep->e_wmesg, td->td_wmesg, WMESGLEN);
615 ep->e_wmesg[WMESGLEN] = 0;
619 * Fake up portions of the proc structure copied out by the sysctl
620 * to return useful information. Note that using td_pri directly
621 * is messy because it includes critial section data so we fake
622 * up an rtprio.prio for threads.
626 xp->p_rtprio.type = RTP_PRIO_THREAD;
627 xp->p_rtprio.prio = td->td_pri & TDPRI_MASK;
633 * Fill in an eproc structure for the specified process.
636 fill_eproc(struct proc *p, struct eproc *ep)
640 fill_eproc_td(p->p_thread, ep, NULL);
644 ep->e_ucred = *p->p_ucred;
647 ep->e_procsig = *p->p_procsig;
649 if (p->p_stat != SIDL && (p->p_flag & P_ZOMBIE) == 0 &&
650 p->p_vmspace != NULL) {
651 struct vmspace *vm = p->p_vmspace;
653 ep->e_vm.vm_rssize = vmspace_resident_count(vm); /*XXX*/
656 ep->e_ppid = p->p_pptr->p_pid;
658 ep->e_pgid = p->p_pgrp->pg_id;
659 ep->e_jobc = p->p_pgrp->pg_jobc;
660 ep->e_sess = p->p_pgrp->pg_session;
663 bcopy(ep->e_sess->s_login, ep->e_login, sizeof(ep->e_login));
664 if (ep->e_sess->s_ttyvp)
665 ep->e_flag = EPROC_CTTY;
666 if (p->p_session && SESS_LEADER(p))
667 ep->e_flag |= EPROC_SLEADER;
670 if ((p->p_flag & P_CONTROLT) &&
671 (ep->e_sess != NULL) &&
672 ((tp = ep->e_sess->s_ttyp) != NULL)) {
673 ep->e_tdev = dev2udev(tp->t_dev);
674 ep->e_tpgid = tp->t_pgrp ? tp->t_pgrp->pg_id : NO_PID;
675 ep->e_tsess = tp->t_session;
679 if (p->p_ucred->cr_prison)
680 ep->e_jailid = p->p_ucred->cr_prison->pr_id;
685 * Locate a process on the zombie list. Return a held process or NULL.
692 LIST_FOREACH(p, &zombproc, p_list)
699 sysctl_out_proc(struct proc *p, struct sysctl_req *req, int flags)
701 struct kinfo_proc ki;
703 int skp = 1, had_output = 0;
706 fill_kinfo_proc(p, &ki);
707 if ((flags & KERN_PROC_FLAG_LWP) == 0)
709 FOREACH_LWP_IN_PROC(lp, p) {
710 fill_kinfo_lwp(lp, &ki.kp_lwp);
713 error = SYSCTL_OUT(req, &ki, sizeof(ki));
719 /* We need to output at least the proc, even if there is no lwp. */
723 if (!doingzomb && pid && (pfind(pid) != p))
725 if (doingzomb && zpfind(pid) != p)
732 sysctl_kern_proc(SYSCTL_HANDLER_ARGS)
734 int *name = (int*) arg1;
735 int oid = oidp->oid_number;
736 u_int namelen = arg2;
738 struct proclist *plist;
739 int doingzomb, flags = 0;
742 struct ucred *cr1 = curproc->p_ucred;
744 flags = oid & KERN_PROC_FLAGMASK;
745 oid &= ~KERN_PROC_FLAGMASK;
747 if ((oid == KERN_PROC_ALL && namelen != 0) ||
748 (oid != KERN_PROC_ALL && namelen != 1))
751 if (oid == KERN_PROC_PID) {
752 p = pfind((pid_t)name[0]);
755 if (!PRISON_CHECK(cr1, p->p_ucred))
757 error = sysctl_out_proc(p, req, flags);
762 /* overestimate by 5 procs */
763 error = SYSCTL_OUT(req, 0, sizeof (struct kinfo_proc) * 5);
767 for (doingzomb = 0; doingzomb <= 1; doingzomb++) {
772 LIST_FOREACH_MUTABLE(p, plist, p_list, np) {
774 * Show a user only their processes.
776 if ((!ps_showallprocs) && p_trespass(cr1, p->p_ucred))
779 * Skip embryonic processes.
781 if (p->p_stat == SIDL)
784 * TODO - make more efficient (see notes below).
789 /* could do this by traversing pgrp */
790 if (p->p_pgrp == NULL ||
791 p->p_pgrp->pg_id != (pid_t)name[0])
796 if ((p->p_flag & P_CONTROLT) == 0 ||
797 p->p_session == NULL ||
798 p->p_session->s_ttyp == NULL ||
799 dev2udev(p->p_session->s_ttyp->t_dev) !=
805 if (p->p_ucred == NULL ||
806 p->p_ucred->cr_uid != (uid_t)name[0])
811 if (p->p_ucred == NULL ||
812 p->p_ucred->cr_ruid != (uid_t)name[0])
817 if (!PRISON_CHECK(cr1, p->p_ucred))
820 error = sysctl_out_proc(p, req, flags);
828 * Iterate over all active cpus and scan their thread list. Start
829 * with the next logical cpu and end with our original cpu. We
830 * migrate our own thread to each target cpu in order to safely scan
831 * its thread list. In the last loop we migrate back to our original
834 origcpu = mycpu->gd_cpuid;
835 if (!ps_showallthreads || jailed(cr1))
838 for (n = 1; n <= ncpus; ++n) {
842 nid = (origcpu + n) % ncpus;
843 if ((smp_active_mask & (1 << nid)) == 0)
845 rgd = globaldata_find(nid);
846 lwkt_setcpu_self(rgd);
848 TAILQ_FOREACH(td, &mycpu->gd_tdallq, td_allq) {
851 switch (oidp->oid_number) {
861 error = sysctl_out_proc(NULL, td, req, doingzomb);
873 * This sysctl allows a process to retrieve the argument list or process
874 * title for another process without groping around in the address space
875 * of the other process. It also allow a process to set its own "process
876 * title to a string of its own choice.
879 sysctl_kern_proc_args(SYSCTL_HANDLER_ARGS)
881 int *name = (int*) arg1;
882 u_int namelen = arg2;
886 struct ucred *cr1 = curproc->p_ucred;
891 p = pfind((pid_t)name[0]);
895 if ((!ps_argsopen) && p_trespass(cr1, p->p_ucred))
898 if (req->newptr && curproc != p)
901 if (req->oldptr && p->p_args != NULL)
902 error = SYSCTL_OUT(req, p->p_args->ar_args, p->p_args->ar_length);
903 if (req->newptr == NULL)
906 if (p->p_args && --p->p_args->ar_ref == 0)
907 FREE(p->p_args, M_PARGS);
910 if (req->newlen + sizeof(struct pargs) > ps_arg_cache_limit)
913 MALLOC(pa, struct pargs *, sizeof(struct pargs) + req->newlen,
916 pa->ar_length = req->newlen;
917 error = SYSCTL_IN(req, pa->ar_args, req->newlen);
925 SYSCTL_NODE(_kern, KERN_PROC, proc, CTLFLAG_RD, 0, "Process table");
927 SYSCTL_PROC(_kern_proc, KERN_PROC_ALL, all, CTLFLAG_RD|CTLTYPE_STRUCT,
928 0, 0, sysctl_kern_proc, "S,proc", "Return entire process table");
930 SYSCTL_NODE(_kern_proc, KERN_PROC_PGRP, pgrp, CTLFLAG_RD,
931 sysctl_kern_proc, "Process table");
933 SYSCTL_NODE(_kern_proc, KERN_PROC_TTY, tty, CTLFLAG_RD,
934 sysctl_kern_proc, "Process table");
936 SYSCTL_NODE(_kern_proc, KERN_PROC_UID, uid, CTLFLAG_RD,
937 sysctl_kern_proc, "Process table");
939 SYSCTL_NODE(_kern_proc, KERN_PROC_RUID, ruid, CTLFLAG_RD,
940 sysctl_kern_proc, "Process table");
942 SYSCTL_NODE(_kern_proc, KERN_PROC_PID, pid, CTLFLAG_RD,
943 sysctl_kern_proc, "Process table");
945 SYSCTL_NODE(_kern_proc, (KERN_PROC_ALL | KERN_PROC_FLAG_LWP), all_lwp, CTLFLAG_RD,
946 sysctl_kern_proc, "Process table");
948 SYSCTL_NODE(_kern_proc, (KERN_PROC_PGRP | KERN_PROC_FLAG_LWP), pgrp_lwp, CTLFLAG_RD,
949 sysctl_kern_proc, "Process table");
951 SYSCTL_NODE(_kern_proc, (KERN_PROC_TTY | KERN_PROC_FLAG_LWP), tty_lwp, CTLFLAG_RD,
952 sysctl_kern_proc, "Process table");
954 SYSCTL_NODE(_kern_proc, (KERN_PROC_UID | KERN_PROC_FLAG_LWP), uid_lwp, CTLFLAG_RD,
955 sysctl_kern_proc, "Process table");
957 SYSCTL_NODE(_kern_proc, (KERN_PROC_RUID | KERN_PROC_FLAG_LWP), ruid_lwp, CTLFLAG_RD,
958 sysctl_kern_proc, "Process table");
960 SYSCTL_NODE(_kern_proc, (KERN_PROC_PID | KERN_PROC_FLAG_LWP), pid_lwp, CTLFLAG_RD,
961 sysctl_kern_proc, "Process table");
963 SYSCTL_NODE(_kern_proc, KERN_PROC_ARGS, args, CTLFLAG_RW | CTLFLAG_ANYBODY,
964 sysctl_kern_proc_args, "Process argument list");