1df8bae1dSRodney W. Grimes /* 2df8bae1dSRodney W. Grimes * Copyright (c) 1982, 1986, 1989, 1991, 1993 3df8bae1dSRodney W. Grimes * The Regents of the University of California. All rights reserved. 4df8bae1dSRodney W. Grimes * 5df8bae1dSRodney W. Grimes * Redistribution and use in source and binary forms, with or without 6df8bae1dSRodney W. Grimes * modification, are permitted provided that the following conditions 7df8bae1dSRodney W. Grimes * are met: 8df8bae1dSRodney W. Grimes * 1. Redistributions of source code must retain the above copyright 9df8bae1dSRodney W. Grimes * notice, this list of conditions and the following disclaimer. 10df8bae1dSRodney W. Grimes * 2. Redistributions in binary form must reproduce the above copyright 11df8bae1dSRodney W. Grimes * notice, this list of conditions and the following disclaimer in the 12df8bae1dSRodney W. Grimes * documentation and/or other materials provided with the distribution. 13df8bae1dSRodney W. Grimes * 3. All advertising materials mentioning features or use of this software 14df8bae1dSRodney W. Grimes * must display the following acknowledgement: 15df8bae1dSRodney W. Grimes * This product includes software developed by the University of 16df8bae1dSRodney W. Grimes * California, Berkeley and its contributors. 17df8bae1dSRodney W. Grimes * 4. Neither the name of the University nor the names of its contributors 18df8bae1dSRodney W. Grimes * may be used to endorse or promote products derived from this software 19df8bae1dSRodney W. Grimes * without specific prior written permission. 20df8bae1dSRodney W. Grimes * 21df8bae1dSRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22df8bae1dSRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23df8bae1dSRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24df8bae1dSRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25df8bae1dSRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26df8bae1dSRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27df8bae1dSRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28df8bae1dSRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29df8bae1dSRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30df8bae1dSRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31df8bae1dSRodney W. Grimes * SUCH DAMAGE. 32df8bae1dSRodney W. Grimes * 33b75356e1SJeffrey Hsu * @(#)kern_proc.c 8.7 (Berkeley) 2/14/95 34c3aac50fSPeter Wemm * $FreeBSD$ 35df8bae1dSRodney W. Grimes */ 36df8bae1dSRodney W. Grimes 37df8bae1dSRodney W. Grimes #include <sys/param.h> 38df8bae1dSRodney W. Grimes #include <sys/systm.h> 39df8bae1dSRodney W. Grimes #include <sys/kernel.h> 40972f9b20SPoul-Henning Kamp #include <sys/sysctl.h> 41df8bae1dSRodney W. Grimes #include <sys/malloc.h> 42b9df5231SPoul-Henning Kamp #include <sys/proc.h> 4362d6ce3aSDon Lewis #include <sys/filedesc.h> 44df8bae1dSRodney W. Grimes #include <sys/tty.h> 45bb56ec4aSPoul-Henning Kamp #include <sys/signalvar.h> 46efeaf95aSDavid Greenman #include <vm/vm.h> 47996c772fSJohn Dyson #include <sys/lock.h> 48efeaf95aSDavid Greenman #include <vm/pmap.h> 49efeaf95aSDavid Greenman #include <vm/vm_map.h> 50efeaf95aSDavid Greenman #include <sys/user.h> 512d8acc0fSJohn Dyson #include <vm/vm_zone.h> 52df8bae1dSRodney W. Grimes 53a1c995b6SPoul-Henning Kamp static MALLOC_DEFINE(M_PGRP, "pgrp", "process group header"); 54a1c995b6SPoul-Henning Kamp MALLOC_DEFINE(M_SESSION, "session", "session header"); 55876a94eeSBruce Evans static MALLOC_DEFINE(M_PROC, "proc", "Proc structures"); 56a1c995b6SPoul-Henning Kamp MALLOC_DEFINE(M_SUBPROC, "subproc", "Proc sub-structures"); 5755166637SPoul-Henning Kamp 5887b6de2bSPoul-Henning Kamp static void pgdelete __P((struct pgrp *)); 5926f9a767SRodney W. Grimes 60df8bae1dSRodney W. Grimes /* 61df8bae1dSRodney W. Grimes * Structure associated with user cacheing. 62df8bae1dSRodney W. Grimes */ 63b75356e1SJeffrey Hsu struct uidinfo { 64b75356e1SJeffrey Hsu LIST_ENTRY(uidinfo) ui_hash; 65df8bae1dSRodney W. Grimes uid_t ui_uid; 66df8bae1dSRodney W. Grimes long ui_proccnt; 67ecf72308SBrian Feldman rlim_t ui_sbsize; 68b75356e1SJeffrey Hsu }; 69b75356e1SJeffrey Hsu #define UIHASH(uid) (&uihashtbl[(uid) & uihash]) 70303b270bSEivind Eklund static LIST_HEAD(uihashhead, uidinfo) *uihashtbl; 7187b6de2bSPoul-Henning Kamp static u_long uihash; /* size of hash table - 1 */ 72df8bae1dSRodney W. Grimes 7398d93822SBruce Evans static void orphanpg __P((struct pgrp *pg)); 7498d93822SBruce Evans 75df8bae1dSRodney W. Grimes /* 76b75356e1SJeffrey Hsu * Other process lists 77b75356e1SJeffrey Hsu */ 78b75356e1SJeffrey Hsu struct pidhashhead *pidhashtbl; 79b75356e1SJeffrey Hsu u_long pidhash; 80b75356e1SJeffrey Hsu struct pgrphashhead *pgrphashtbl; 81b75356e1SJeffrey Hsu u_long pgrphash; 82b75356e1SJeffrey Hsu struct proclist allproc; 83b75356e1SJeffrey Hsu struct proclist zombproc; 842d8acc0fSJohn Dyson vm_zone_t proc_zone; 85b75356e1SJeffrey Hsu 86b75356e1SJeffrey Hsu /* 87b75356e1SJeffrey Hsu * Initialize global process hashing structures. 88df8bae1dSRodney W. Grimes */ 8926f9a767SRodney W. Grimes void 90b75356e1SJeffrey Hsu procinit() 91df8bae1dSRodney W. Grimes { 92df8bae1dSRodney W. Grimes 93b75356e1SJeffrey Hsu LIST_INIT(&allproc); 94b75356e1SJeffrey Hsu LIST_INIT(&zombproc); 95b75356e1SJeffrey Hsu pidhashtbl = hashinit(maxproc / 4, M_PROC, &pidhash); 96b75356e1SJeffrey Hsu pgrphashtbl = hashinit(maxproc / 4, M_PROC, &pgrphash); 97df8bae1dSRodney W. Grimes uihashtbl = hashinit(maxproc / 16, M_PROC, &uihash); 982d8acc0fSJohn Dyson proc_zone = zinit("PROC", sizeof (struct proc), 0, 0, 5); 99df8bae1dSRodney W. Grimes } 100df8bae1dSRodney W. Grimes 101df8bae1dSRodney W. Grimes /* 102df8bae1dSRodney W. Grimes * Change the count associated with number of processes 103df8bae1dSRodney W. Grimes * a given user is using. 104df8bae1dSRodney W. Grimes */ 105df8bae1dSRodney W. Grimes int 106df8bae1dSRodney W. Grimes chgproccnt(uid, diff) 107df8bae1dSRodney W. Grimes uid_t uid; 108df8bae1dSRodney W. Grimes int diff; 109df8bae1dSRodney W. Grimes { 110b75356e1SJeffrey Hsu register struct uidinfo *uip; 111b75356e1SJeffrey Hsu register struct uihashhead *uipp; 112df8bae1dSRodney W. Grimes 113b75356e1SJeffrey Hsu uipp = UIHASH(uid); 1141b727751SPoul-Henning Kamp LIST_FOREACH(uip, uipp, ui_hash) 115df8bae1dSRodney W. Grimes if (uip->ui_uid == uid) 116df8bae1dSRodney W. Grimes break; 117df8bae1dSRodney W. Grimes if (uip) { 118df8bae1dSRodney W. Grimes uip->ui_proccnt += diff; 119df8bae1dSRodney W. Grimes if (uip->ui_proccnt < 0) 120df8bae1dSRodney W. Grimes panic("chgproccnt: procs < 0"); 121ecf72308SBrian Feldman if (uip->ui_proccnt > 0 || uip->ui_sbsize > 0) 122ecf72308SBrian Feldman return (uip->ui_proccnt); 123b75356e1SJeffrey Hsu LIST_REMOVE(uip, ui_hash); 124df8bae1dSRodney W. Grimes FREE(uip, M_PROC); 125df8bae1dSRodney W. Grimes return (0); 126df8bae1dSRodney W. Grimes } 127df8bae1dSRodney W. Grimes if (diff <= 0) { 128df8bae1dSRodney W. Grimes if (diff == 0) 129df8bae1dSRodney W. Grimes return(0); 130df8bae1dSRodney W. Grimes panic("chgproccnt: lost user"); 131df8bae1dSRodney W. Grimes } 132df8bae1dSRodney W. Grimes MALLOC(uip, struct uidinfo *, sizeof(*uip), M_PROC, M_WAITOK); 133b75356e1SJeffrey Hsu LIST_INSERT_HEAD(uipp, uip, ui_hash); 134df8bae1dSRodney W. Grimes uip->ui_uid = uid; 135df8bae1dSRodney W. Grimes uip->ui_proccnt = diff; 136ecf72308SBrian Feldman uip->ui_sbsize = 0; 137ecf72308SBrian Feldman return (diff); 138ecf72308SBrian Feldman } 139ecf72308SBrian Feldman 140ecf72308SBrian Feldman /* 141ecf72308SBrian Feldman * Change the total socket buffer size a user has used. 142ecf72308SBrian Feldman */ 143ecf72308SBrian Feldman rlim_t 144ecf72308SBrian Feldman chgsbsize(uid, diff) 145ecf72308SBrian Feldman uid_t uid; 146ecf72308SBrian Feldman rlim_t diff; 147ecf72308SBrian Feldman { 148ecf72308SBrian Feldman register struct uidinfo *uip; 149ecf72308SBrian Feldman register struct uihashhead *uipp; 150ecf72308SBrian Feldman 151ecf72308SBrian Feldman uipp = UIHASH(uid); 1521b727751SPoul-Henning Kamp LIST_FOREACH(uip, uipp, ui_hash) 153ecf72308SBrian Feldman if (uip->ui_uid == uid) 154ecf72308SBrian Feldman break; 155ecf72308SBrian Feldman if (diff <= 0) { 156ecf72308SBrian Feldman if (diff == 0) 157ecf72308SBrian Feldman return (uip ? uip->ui_sbsize : 0); 158ecf72308SBrian Feldman KASSERT(uip != NULL, ("uidinfo (%d) gone", uid)); 159ecf72308SBrian Feldman } 160ecf72308SBrian Feldman if (uip) { 161ecf72308SBrian Feldman uip->ui_sbsize += diff; 162ecf72308SBrian Feldman if (uip->ui_sbsize == 0 && uip->ui_proccnt == 0) { 163ecf72308SBrian Feldman LIST_REMOVE(uip, ui_hash); 164ecf72308SBrian Feldman FREE(uip, M_PROC); 165ecf72308SBrian Feldman return (0); 166ecf72308SBrian Feldman } 167ecf72308SBrian Feldman return (uip->ui_sbsize); 168ecf72308SBrian Feldman } 169ecf72308SBrian Feldman MALLOC(uip, struct uidinfo *, sizeof(*uip), M_PROC, M_WAITOK); 170ecf72308SBrian Feldman LIST_INSERT_HEAD(uipp, uip, ui_hash); 171ecf72308SBrian Feldman uip->ui_uid = uid; 172ecf72308SBrian Feldman uip->ui_proccnt = 0; 173ecf72308SBrian Feldman uip->ui_sbsize = diff; 174df8bae1dSRodney W. Grimes return (diff); 175df8bae1dSRodney W. Grimes } 176df8bae1dSRodney W. Grimes 177df8bae1dSRodney W. Grimes /* 178df8bae1dSRodney W. Grimes * Is p an inferior of the current process? 179df8bae1dSRodney W. Grimes */ 18026f9a767SRodney W. Grimes int 181df8bae1dSRodney W. Grimes inferior(p) 182df8bae1dSRodney W. Grimes register struct proc *p; 183df8bae1dSRodney W. Grimes { 184df8bae1dSRodney W. Grimes 185df8bae1dSRodney W. Grimes for (; p != curproc; p = p->p_pptr) 186df8bae1dSRodney W. Grimes if (p->p_pid == 0) 187df8bae1dSRodney W. Grimes return (0); 188df8bae1dSRodney W. Grimes return (1); 189df8bae1dSRodney W. Grimes } 190df8bae1dSRodney W. Grimes 191df8bae1dSRodney W. Grimes /* 192df8bae1dSRodney W. Grimes * Locate a process by number 193df8bae1dSRodney W. Grimes */ 194df8bae1dSRodney W. Grimes struct proc * 195df8bae1dSRodney W. Grimes pfind(pid) 196df8bae1dSRodney W. Grimes register pid_t pid; 197df8bae1dSRodney W. Grimes { 198df8bae1dSRodney W. Grimes register struct proc *p; 199df8bae1dSRodney W. Grimes 2001b727751SPoul-Henning Kamp LIST_FOREACH(p, PIDHASH(pid), p_hash) 201df8bae1dSRodney W. Grimes if (p->p_pid == pid) 202df8bae1dSRodney W. Grimes return (p); 203df8bae1dSRodney W. Grimes return (NULL); 204df8bae1dSRodney W. Grimes } 205df8bae1dSRodney W. Grimes 206df8bae1dSRodney W. Grimes /* 207df8bae1dSRodney W. Grimes * Locate a process group by number 208df8bae1dSRodney W. Grimes */ 209df8bae1dSRodney W. Grimes struct pgrp * 210df8bae1dSRodney W. Grimes pgfind(pgid) 211df8bae1dSRodney W. Grimes register pid_t pgid; 212df8bae1dSRodney W. Grimes { 213df8bae1dSRodney W. Grimes register struct pgrp *pgrp; 214df8bae1dSRodney W. Grimes 2151b727751SPoul-Henning Kamp LIST_FOREACH(pgrp, PGRPHASH(pgid), pg_hash) 216df8bae1dSRodney W. Grimes if (pgrp->pg_id == pgid) 217df8bae1dSRodney W. Grimes return (pgrp); 218df8bae1dSRodney W. Grimes return (NULL); 219df8bae1dSRodney W. Grimes } 220df8bae1dSRodney W. Grimes 221df8bae1dSRodney W. Grimes /* 222df8bae1dSRodney W. Grimes * Move p to a new or existing process group (and session) 223df8bae1dSRodney W. Grimes */ 22426f9a767SRodney W. Grimes int 225df8bae1dSRodney W. Grimes enterpgrp(p, pgid, mksess) 226df8bae1dSRodney W. Grimes register struct proc *p; 227df8bae1dSRodney W. Grimes pid_t pgid; 228df8bae1dSRodney W. Grimes int mksess; 229df8bae1dSRodney W. Grimes { 230df8bae1dSRodney W. Grimes register struct pgrp *pgrp = pgfind(pgid); 231df8bae1dSRodney W. Grimes 2325526d2d9SEivind Eklund KASSERT(pgrp == NULL || !mksess, 2335526d2d9SEivind Eklund ("enterpgrp: setsid into non-empty pgrp")); 2345526d2d9SEivind Eklund KASSERT(!SESS_LEADER(p), 2355526d2d9SEivind Eklund ("enterpgrp: session leader attempted setpgrp")); 236219cbf59SEivind Eklund 237df8bae1dSRodney W. Grimes if (pgrp == NULL) { 238df8bae1dSRodney W. Grimes pid_t savepid = p->p_pid; 239df8bae1dSRodney W. Grimes struct proc *np; 240df8bae1dSRodney W. Grimes /* 241df8bae1dSRodney W. Grimes * new process group 242df8bae1dSRodney W. Grimes */ 2435526d2d9SEivind Eklund KASSERT(p->p_pid == pgid, 2445526d2d9SEivind Eklund ("enterpgrp: new pgrp and pid != pgid")); 245df8bae1dSRodney W. Grimes MALLOC(pgrp, struct pgrp *, sizeof(struct pgrp), M_PGRP, 246df8bae1dSRodney W. Grimes M_WAITOK); 247df8bae1dSRodney W. Grimes if ((np = pfind(savepid)) == NULL || np != p) 248df8bae1dSRodney W. Grimes return (ESRCH); 249df8bae1dSRodney W. Grimes if (mksess) { 250df8bae1dSRodney W. Grimes register struct session *sess; 251df8bae1dSRodney W. Grimes 252df8bae1dSRodney W. Grimes /* 253df8bae1dSRodney W. Grimes * new session 254df8bae1dSRodney W. Grimes */ 255df8bae1dSRodney W. Grimes MALLOC(sess, struct session *, sizeof(struct session), 256df8bae1dSRodney W. Grimes M_SESSION, M_WAITOK); 257df8bae1dSRodney W. Grimes sess->s_leader = p; 258643a8daaSDon Lewis sess->s_sid = p->p_pid; 259df8bae1dSRodney W. Grimes sess->s_count = 1; 260df8bae1dSRodney W. Grimes sess->s_ttyvp = NULL; 261df8bae1dSRodney W. Grimes sess->s_ttyp = NULL; 262df8bae1dSRodney W. Grimes bcopy(p->p_session->s_login, sess->s_login, 263df8bae1dSRodney W. Grimes sizeof(sess->s_login)); 264df8bae1dSRodney W. Grimes p->p_flag &= ~P_CONTROLT; 265df8bae1dSRodney W. Grimes pgrp->pg_session = sess; 2665526d2d9SEivind Eklund KASSERT(p == curproc, 2675526d2d9SEivind Eklund ("enterpgrp: mksession and p != curproc")); 268df8bae1dSRodney W. Grimes } else { 269df8bae1dSRodney W. Grimes pgrp->pg_session = p->p_session; 270df8bae1dSRodney W. Grimes pgrp->pg_session->s_count++; 271df8bae1dSRodney W. Grimes } 272df8bae1dSRodney W. Grimes pgrp->pg_id = pgid; 273b75356e1SJeffrey Hsu LIST_INIT(&pgrp->pg_members); 274b75356e1SJeffrey Hsu LIST_INSERT_HEAD(PGRPHASH(pgid), pgrp, pg_hash); 275df8bae1dSRodney W. Grimes pgrp->pg_jobc = 0; 276831d27a9SDon Lewis SLIST_INIT(&pgrp->pg_sigiolst); 277df8bae1dSRodney W. Grimes } else if (pgrp == p->p_pgrp) 278df8bae1dSRodney W. Grimes return (0); 279df8bae1dSRodney W. Grimes 280df8bae1dSRodney W. Grimes /* 281df8bae1dSRodney W. Grimes * Adjust eligibility of affected pgrps to participate in job control. 282df8bae1dSRodney W. Grimes * Increment eligibility counts before decrementing, otherwise we 283df8bae1dSRodney W. Grimes * could reach 0 spuriously during the first call. 284df8bae1dSRodney W. Grimes */ 285df8bae1dSRodney W. Grimes fixjobc(p, pgrp, 1); 286df8bae1dSRodney W. Grimes fixjobc(p, p->p_pgrp, 0); 287df8bae1dSRodney W. Grimes 288b75356e1SJeffrey Hsu LIST_REMOVE(p, p_pglist); 2891b727751SPoul-Henning Kamp if (LIST_EMPTY(&p->p_pgrp->pg_members)) 290df8bae1dSRodney W. Grimes pgdelete(p->p_pgrp); 291df8bae1dSRodney W. Grimes p->p_pgrp = pgrp; 292b75356e1SJeffrey Hsu LIST_INSERT_HEAD(&pgrp->pg_members, p, p_pglist); 293df8bae1dSRodney W. Grimes return (0); 294df8bae1dSRodney W. Grimes } 295df8bae1dSRodney W. Grimes 296df8bae1dSRodney W. Grimes /* 297df8bae1dSRodney W. Grimes * remove process from process group 298df8bae1dSRodney W. Grimes */ 29926f9a767SRodney W. Grimes int 300df8bae1dSRodney W. Grimes leavepgrp(p) 301df8bae1dSRodney W. Grimes register struct proc *p; 302df8bae1dSRodney W. Grimes { 303df8bae1dSRodney W. Grimes 304b75356e1SJeffrey Hsu LIST_REMOVE(p, p_pglist); 3051b727751SPoul-Henning Kamp if (LIST_EMPTY(&p->p_pgrp->pg_members)) 306df8bae1dSRodney W. Grimes pgdelete(p->p_pgrp); 307df8bae1dSRodney W. Grimes p->p_pgrp = 0; 308df8bae1dSRodney W. Grimes return (0); 309df8bae1dSRodney W. Grimes } 310df8bae1dSRodney W. Grimes 311df8bae1dSRodney W. Grimes /* 312df8bae1dSRodney W. Grimes * delete a process group 313df8bae1dSRodney W. Grimes */ 31487b6de2bSPoul-Henning Kamp static void 315df8bae1dSRodney W. Grimes pgdelete(pgrp) 316df8bae1dSRodney W. Grimes register struct pgrp *pgrp; 317df8bae1dSRodney W. Grimes { 318df8bae1dSRodney W. Grimes 319831d27a9SDon Lewis /* 320831d27a9SDon Lewis * Reset any sigio structures pointing to us as a result of 321831d27a9SDon Lewis * F_SETOWN with our pgid. 322831d27a9SDon Lewis */ 323831d27a9SDon Lewis funsetownlst(&pgrp->pg_sigiolst); 324831d27a9SDon Lewis 325df8bae1dSRodney W. Grimes if (pgrp->pg_session->s_ttyp != NULL && 326df8bae1dSRodney W. Grimes pgrp->pg_session->s_ttyp->t_pgrp == pgrp) 327df8bae1dSRodney W. Grimes pgrp->pg_session->s_ttyp->t_pgrp = NULL; 328b75356e1SJeffrey Hsu LIST_REMOVE(pgrp, pg_hash); 329df8bae1dSRodney W. Grimes if (--pgrp->pg_session->s_count == 0) 330df8bae1dSRodney W. Grimes FREE(pgrp->pg_session, M_SESSION); 331df8bae1dSRodney W. Grimes FREE(pgrp, M_PGRP); 332df8bae1dSRodney W. Grimes } 333df8bae1dSRodney W. Grimes 334df8bae1dSRodney W. Grimes /* 335df8bae1dSRodney W. Grimes * Adjust pgrp jobc counters when specified process changes process group. 336df8bae1dSRodney W. Grimes * We count the number of processes in each process group that "qualify" 337df8bae1dSRodney W. Grimes * the group for terminal job control (those with a parent in a different 338df8bae1dSRodney W. Grimes * process group of the same session). If that count reaches zero, the 339df8bae1dSRodney W. Grimes * process group becomes orphaned. Check both the specified process' 340df8bae1dSRodney W. Grimes * process group and that of its children. 341df8bae1dSRodney W. Grimes * entering == 0 => p is leaving specified group. 342df8bae1dSRodney W. Grimes * entering == 1 => p is entering specified group. 343df8bae1dSRodney W. Grimes */ 34426f9a767SRodney W. Grimes void 345df8bae1dSRodney W. Grimes fixjobc(p, pgrp, entering) 346df8bae1dSRodney W. Grimes register struct proc *p; 347df8bae1dSRodney W. Grimes register struct pgrp *pgrp; 348df8bae1dSRodney W. Grimes int entering; 349df8bae1dSRodney W. Grimes { 350df8bae1dSRodney W. Grimes register struct pgrp *hispgrp; 351df8bae1dSRodney W. Grimes register struct session *mysession = pgrp->pg_session; 352df8bae1dSRodney W. Grimes 353df8bae1dSRodney W. Grimes /* 354df8bae1dSRodney W. Grimes * Check p's parent to see whether p qualifies its own process 355df8bae1dSRodney W. Grimes * group; if so, adjust count for p's process group. 356df8bae1dSRodney W. Grimes */ 357df8bae1dSRodney W. Grimes if ((hispgrp = p->p_pptr->p_pgrp) != pgrp && 358dfd5dee1SPeter Wemm hispgrp->pg_session == mysession) { 359df8bae1dSRodney W. Grimes if (entering) 360df8bae1dSRodney W. Grimes pgrp->pg_jobc++; 361df8bae1dSRodney W. Grimes else if (--pgrp->pg_jobc == 0) 362df8bae1dSRodney W. Grimes orphanpg(pgrp); 363dfd5dee1SPeter Wemm } 364df8bae1dSRodney W. Grimes 365df8bae1dSRodney W. Grimes /* 366df8bae1dSRodney W. Grimes * Check this process' children to see whether they qualify 367df8bae1dSRodney W. Grimes * their process groups; if so, adjust counts for children's 368df8bae1dSRodney W. Grimes * process groups. 369df8bae1dSRodney W. Grimes */ 3701b727751SPoul-Henning Kamp LIST_FOREACH(p, &p->p_children, p_sibling) 371df8bae1dSRodney W. Grimes if ((hispgrp = p->p_pgrp) != pgrp && 372df8bae1dSRodney W. Grimes hispgrp->pg_session == mysession && 373dfd5dee1SPeter Wemm p->p_stat != SZOMB) { 374df8bae1dSRodney W. Grimes if (entering) 375df8bae1dSRodney W. Grimes hispgrp->pg_jobc++; 376df8bae1dSRodney W. Grimes else if (--hispgrp->pg_jobc == 0) 377df8bae1dSRodney W. Grimes orphanpg(hispgrp); 378df8bae1dSRodney W. Grimes } 379dfd5dee1SPeter Wemm } 380df8bae1dSRodney W. Grimes 381df8bae1dSRodney W. Grimes /* 382df8bae1dSRodney W. Grimes * A process group has become orphaned; 383df8bae1dSRodney W. Grimes * if there are any stopped processes in the group, 384df8bae1dSRodney W. Grimes * hang-up all process in that group. 385df8bae1dSRodney W. Grimes */ 386df8bae1dSRodney W. Grimes static void 387df8bae1dSRodney W. Grimes orphanpg(pg) 388df8bae1dSRodney W. Grimes struct pgrp *pg; 389df8bae1dSRodney W. Grimes { 390df8bae1dSRodney W. Grimes register struct proc *p; 391df8bae1dSRodney W. Grimes 3921b727751SPoul-Henning Kamp LIST_FOREACH(p, &pg->pg_members, p_pglist) { 393df8bae1dSRodney W. Grimes if (p->p_stat == SSTOP) { 3941b727751SPoul-Henning Kamp LIST_FOREACH(p, &pg->pg_members, p_pglist) { 395df8bae1dSRodney W. Grimes psignal(p, SIGHUP); 396df8bae1dSRodney W. Grimes psignal(p, SIGCONT); 397df8bae1dSRodney W. Grimes } 398df8bae1dSRodney W. Grimes return; 399df8bae1dSRodney W. Grimes } 400df8bae1dSRodney W. Grimes } 401df8bae1dSRodney W. Grimes } 402df8bae1dSRodney W. Grimes 403831031ceSBruce Evans #include "opt_ddb.h" 404831031ceSBruce Evans #ifdef DDB 405831031ceSBruce Evans #include <ddb/ddb.h> 406831031ceSBruce Evans 407831031ceSBruce Evans DB_SHOW_COMMAND(pgrpdump, pgrpdump) 408df8bae1dSRodney W. Grimes { 409df8bae1dSRodney W. Grimes register struct pgrp *pgrp; 410df8bae1dSRodney W. Grimes register struct proc *p; 411876a94eeSBruce Evans register int i; 412df8bae1dSRodney W. Grimes 413b75356e1SJeffrey Hsu for (i = 0; i <= pgrphash; i++) { 4141b727751SPoul-Henning Kamp if (!LIST_EMPTY(&pgrphashtbl[i])) { 415df8bae1dSRodney W. Grimes printf("\tindx %d\n", i); 4161b727751SPoul-Henning Kamp LIST_FOREACH(pgrp, &pgrphashtbl[i], pg_hash) { 417ac1e407bSBruce Evans printf( 418ac1e407bSBruce Evans "\tpgrp %p, pgid %ld, sess %p, sesscnt %d, mem %p\n", 419ac1e407bSBruce Evans (void *)pgrp, (long)pgrp->pg_id, 420ac1e407bSBruce Evans (void *)pgrp->pg_session, 421b75356e1SJeffrey Hsu pgrp->pg_session->s_count, 4221b727751SPoul-Henning Kamp (void *)LIST_FIRST(&pgrp->pg_members)); 4231b727751SPoul-Henning Kamp LIST_FOREACH(p, &pgrp->pg_members, p_pglist) { 424ac1e407bSBruce Evans printf("\t\tpid %ld addr %p pgrp %p\n", 425ac1e407bSBruce Evans (long)p->p_pid, (void *)p, 426ac1e407bSBruce Evans (void *)p->p_pgrp); 427df8bae1dSRodney W. Grimes } 428df8bae1dSRodney W. Grimes } 429df8bae1dSRodney W. Grimes } 430df8bae1dSRodney W. Grimes } 431df8bae1dSRodney W. Grimes } 432831031ceSBruce Evans #endif /* DDB */ 433972f9b20SPoul-Henning Kamp 434972f9b20SPoul-Henning Kamp /* 435972f9b20SPoul-Henning Kamp * Fill in an eproc structure for the specified process. 436972f9b20SPoul-Henning Kamp */ 437972f9b20SPoul-Henning Kamp void 438972f9b20SPoul-Henning Kamp fill_eproc(p, ep) 439972f9b20SPoul-Henning Kamp register struct proc *p; 440972f9b20SPoul-Henning Kamp register struct eproc *ep; 441972f9b20SPoul-Henning Kamp { 442972f9b20SPoul-Henning Kamp register struct tty *tp; 443972f9b20SPoul-Henning Kamp 444972f9b20SPoul-Henning Kamp bzero(ep, sizeof(*ep)); 445972f9b20SPoul-Henning Kamp 446972f9b20SPoul-Henning Kamp ep->e_paddr = p; 447972f9b20SPoul-Henning Kamp if (p->p_cred) { 448972f9b20SPoul-Henning Kamp ep->e_pcred = *p->p_cred; 449972f9b20SPoul-Henning Kamp if (p->p_ucred) 450972f9b20SPoul-Henning Kamp ep->e_ucred = *p->p_ucred; 451972f9b20SPoul-Henning Kamp } 452d8c85307SJulian Elischer if (p->p_procsig) { 453d8c85307SJulian Elischer ep->e_procsig = *p->p_procsig; 454d8c85307SJulian Elischer } 455972f9b20SPoul-Henning Kamp if (p->p_stat != SIDL && p->p_stat != SZOMB && p->p_vmspace != NULL) { 456972f9b20SPoul-Henning Kamp register struct vmspace *vm = p->p_vmspace; 457b1028ad1SLuoqi Chen ep->e_vm = *vm; 458b1028ad1SLuoqi Chen ep->e_vm.vm_rssize = vmspace_resident_count(vm); /*XXX*/ 459972f9b20SPoul-Henning Kamp } 460e29e202cSPeter Wemm if ((p->p_flag & P_INMEM) && p->p_stats) 461e29e202cSPeter Wemm ep->e_stats = *p->p_stats; 462972f9b20SPoul-Henning Kamp if (p->p_pptr) 463972f9b20SPoul-Henning Kamp ep->e_ppid = p->p_pptr->p_pid; 464972f9b20SPoul-Henning Kamp if (p->p_pgrp) { 465972f9b20SPoul-Henning Kamp ep->e_pgid = p->p_pgrp->pg_id; 466972f9b20SPoul-Henning Kamp ep->e_jobc = p->p_pgrp->pg_jobc; 467cd73303cSDavid Greenman ep->e_sess = p->p_pgrp->pg_session; 468cd73303cSDavid Greenman 469cd73303cSDavid Greenman if (ep->e_sess) { 4708735cebcSPeter Wemm bcopy(ep->e_sess->s_login, ep->e_login, sizeof(ep->e_login)); 471cd73303cSDavid Greenman if (ep->e_sess->s_ttyvp) 472cd73303cSDavid Greenman ep->e_flag = EPROC_CTTY; 473cd73303cSDavid Greenman if (p->p_session && SESS_LEADER(p)) 474cd73303cSDavid Greenman ep->e_flag |= EPROC_SLEADER; 475cd73303cSDavid Greenman } 476cd73303cSDavid Greenman } 477972f9b20SPoul-Henning Kamp if ((p->p_flag & P_CONTROLT) && 478972f9b20SPoul-Henning Kamp (ep->e_sess != NULL) && 479972f9b20SPoul-Henning Kamp ((tp = ep->e_sess->s_ttyp) != NULL)) { 480f40ddd55SDoug Rabson ep->e_tdev = dev2udev(tp->t_dev); 481972f9b20SPoul-Henning Kamp ep->e_tpgid = tp->t_pgrp ? tp->t_pgrp->pg_id : NO_PID; 482972f9b20SPoul-Henning Kamp ep->e_tsess = tp->t_session; 483972f9b20SPoul-Henning Kamp } else 4846a0ce002SPoul-Henning Kamp ep->e_tdev = NOUDEV; 485972f9b20SPoul-Henning Kamp if (p->p_wmesg) { 486972f9b20SPoul-Henning Kamp strncpy(ep->e_wmesg, p->p_wmesg, WMESGLEN); 487972f9b20SPoul-Henning Kamp ep->e_wmesg[WMESGLEN] = 0; 488972f9b20SPoul-Henning Kamp } 489972f9b20SPoul-Henning Kamp } 490972f9b20SPoul-Henning Kamp 4913ce93e4eSPoul-Henning Kamp static struct proc * 4923ce93e4eSPoul-Henning Kamp zpfind(pid_t pid) 4933ce93e4eSPoul-Henning Kamp { 4943ce93e4eSPoul-Henning Kamp struct proc *p; 4953ce93e4eSPoul-Henning Kamp 4961b727751SPoul-Henning Kamp LIST_FOREACH(p, &zombproc, p_list) 4973ce93e4eSPoul-Henning Kamp if (p->p_pid == pid) 4983ce93e4eSPoul-Henning Kamp return (p); 4993ce93e4eSPoul-Henning Kamp return (NULL); 5003ce93e4eSPoul-Henning Kamp } 5013ce93e4eSPoul-Henning Kamp 5023ce93e4eSPoul-Henning Kamp 5033ce93e4eSPoul-Henning Kamp static int 5043ce93e4eSPoul-Henning Kamp sysctl_out_proc(struct proc *p, struct sysctl_req *req, int doingzomb) 5053ce93e4eSPoul-Henning Kamp { 5063ce93e4eSPoul-Henning Kamp struct eproc eproc; 5073ce93e4eSPoul-Henning Kamp int error; 5083ce93e4eSPoul-Henning Kamp pid_t pid = p->p_pid; 5093ce93e4eSPoul-Henning Kamp 5103ce93e4eSPoul-Henning Kamp fill_eproc(p, &eproc); 5113ce93e4eSPoul-Henning Kamp error = SYSCTL_OUT(req,(caddr_t)p, sizeof(struct proc)); 5123ce93e4eSPoul-Henning Kamp if (error) 5133ce93e4eSPoul-Henning Kamp return (error); 5143ce93e4eSPoul-Henning Kamp error = SYSCTL_OUT(req,(caddr_t)&eproc, sizeof(eproc)); 5153ce93e4eSPoul-Henning Kamp if (error) 5163ce93e4eSPoul-Henning Kamp return (error); 5173ce93e4eSPoul-Henning Kamp if (!doingzomb && pid && (pfind(pid) != p)) 5183ce93e4eSPoul-Henning Kamp return EAGAIN; 5193ce93e4eSPoul-Henning Kamp if (doingzomb && zpfind(pid) != p) 5203ce93e4eSPoul-Henning Kamp return EAGAIN; 5213ce93e4eSPoul-Henning Kamp return (0); 5223ce93e4eSPoul-Henning Kamp } 5233ce93e4eSPoul-Henning Kamp 524972f9b20SPoul-Henning Kamp static int 525972f9b20SPoul-Henning Kamp sysctl_kern_proc SYSCTL_HANDLER_ARGS 526972f9b20SPoul-Henning Kamp { 527972f9b20SPoul-Henning Kamp int *name = (int*) arg1; 528972f9b20SPoul-Henning Kamp u_int namelen = arg2; 529972f9b20SPoul-Henning Kamp struct proc *p; 530972f9b20SPoul-Henning Kamp int doingzomb; 531972f9b20SPoul-Henning Kamp int error = 0; 532972f9b20SPoul-Henning Kamp 5333ce93e4eSPoul-Henning Kamp if (oidp->oid_number == KERN_PROC_PID) { 5343ce93e4eSPoul-Henning Kamp if (namelen != 1) 535972f9b20SPoul-Henning Kamp return (EINVAL); 5363ce93e4eSPoul-Henning Kamp p = pfind((pid_t)name[0]); 5373ce93e4eSPoul-Henning Kamp if (!p) 5383ce93e4eSPoul-Henning Kamp return (0); 53975c13541SPoul-Henning Kamp if (!PRISON_CHECK(curproc, p)) 54075c13541SPoul-Henning Kamp return (0); 5413ce93e4eSPoul-Henning Kamp error = sysctl_out_proc(p, req, 0); 5423ce93e4eSPoul-Henning Kamp return (error); 5433ce93e4eSPoul-Henning Kamp } 5443ce93e4eSPoul-Henning Kamp if (oidp->oid_number == KERN_PROC_ALL && !namelen) 5453ce93e4eSPoul-Henning Kamp ; 5463ce93e4eSPoul-Henning Kamp else if (oidp->oid_number != KERN_PROC_ALL && namelen == 1) 5473ce93e4eSPoul-Henning Kamp ; 5483ce93e4eSPoul-Henning Kamp else 5493ce93e4eSPoul-Henning Kamp return (EINVAL); 5503ce93e4eSPoul-Henning Kamp 551972f9b20SPoul-Henning Kamp if (!req->oldptr) { 5523ce93e4eSPoul-Henning Kamp /* overestimate by 5 procs */ 553972f9b20SPoul-Henning Kamp error = SYSCTL_OUT(req, 0, sizeof (struct kinfo_proc) * 5); 554972f9b20SPoul-Henning Kamp if (error) 555972f9b20SPoul-Henning Kamp return (error); 556972f9b20SPoul-Henning Kamp } 5573ce93e4eSPoul-Henning Kamp for (doingzomb=0 ; doingzomb < 2 ; doingzomb++) { 5583ce93e4eSPoul-Henning Kamp if (!doingzomb) 5591b727751SPoul-Henning Kamp p = LIST_FIRST(&allproc); 5603ce93e4eSPoul-Henning Kamp else 5611b727751SPoul-Henning Kamp p = LIST_FIRST(&zombproc); 5621b727751SPoul-Henning Kamp for (; p != 0; p = LIST_NEXT(p, p_list)) { 563972f9b20SPoul-Henning Kamp /* 564972f9b20SPoul-Henning Kamp * Skip embryonic processes. 565972f9b20SPoul-Henning Kamp */ 566972f9b20SPoul-Henning Kamp if (p->p_stat == SIDL) 567972f9b20SPoul-Henning Kamp continue; 568972f9b20SPoul-Henning Kamp /* 569972f9b20SPoul-Henning Kamp * TODO - make more efficient (see notes below). 570972f9b20SPoul-Henning Kamp * do by session. 571972f9b20SPoul-Henning Kamp */ 5723ce93e4eSPoul-Henning Kamp switch (oidp->oid_number) { 573972f9b20SPoul-Henning Kamp 574972f9b20SPoul-Henning Kamp case KERN_PROC_PGRP: 575972f9b20SPoul-Henning Kamp /* could do this by traversing pgrp */ 5763ce93e4eSPoul-Henning Kamp if (p->p_pgrp == NULL || 5773ce93e4eSPoul-Henning Kamp p->p_pgrp->pg_id != (pid_t)name[0]) 578972f9b20SPoul-Henning Kamp continue; 579972f9b20SPoul-Henning Kamp break; 580972f9b20SPoul-Henning Kamp 581972f9b20SPoul-Henning Kamp case KERN_PROC_TTY: 582972f9b20SPoul-Henning Kamp if ((p->p_flag & P_CONTROLT) == 0 || 583972f9b20SPoul-Henning Kamp p->p_session == NULL || 584972f9b20SPoul-Henning Kamp p->p_session->s_ttyp == NULL || 58568f7448fSPoul-Henning Kamp dev2udev(p->p_session->s_ttyp->t_dev) != 58668f7448fSPoul-Henning Kamp (udev_t)name[0]) 587972f9b20SPoul-Henning Kamp continue; 588972f9b20SPoul-Henning Kamp break; 589972f9b20SPoul-Henning Kamp 590972f9b20SPoul-Henning Kamp case KERN_PROC_UID: 5913ce93e4eSPoul-Henning Kamp if (p->p_ucred == NULL || 5923ce93e4eSPoul-Henning Kamp p->p_ucred->cr_uid != (uid_t)name[0]) 593972f9b20SPoul-Henning Kamp continue; 594972f9b20SPoul-Henning Kamp break; 595972f9b20SPoul-Henning Kamp 596972f9b20SPoul-Henning Kamp case KERN_PROC_RUID: 5973ce93e4eSPoul-Henning Kamp if (p->p_ucred == NULL || 5983ce93e4eSPoul-Henning Kamp p->p_cred->p_ruid != (uid_t)name[0]) 599972f9b20SPoul-Henning Kamp continue; 600972f9b20SPoul-Henning Kamp break; 601972f9b20SPoul-Henning Kamp } 602972f9b20SPoul-Henning Kamp 60375c13541SPoul-Henning Kamp if (!PRISON_CHECK(curproc, p)) 60475c13541SPoul-Henning Kamp continue; 60575c13541SPoul-Henning Kamp 6063ce93e4eSPoul-Henning Kamp error = sysctl_out_proc(p, req, doingzomb); 607972f9b20SPoul-Henning Kamp if (error) 608972f9b20SPoul-Henning Kamp return (error); 609972f9b20SPoul-Henning Kamp } 610972f9b20SPoul-Henning Kamp } 611972f9b20SPoul-Henning Kamp return (0); 612972f9b20SPoul-Henning Kamp } 613972f9b20SPoul-Henning Kamp 614b9df5231SPoul-Henning Kamp /* 615b9df5231SPoul-Henning Kamp * This sysctl allows a process to retrieve the argument list or process 616b9df5231SPoul-Henning Kamp * title for another process without groping around in the address space 617b9df5231SPoul-Henning Kamp * of the other process. It also allow a process to set its own "process 618b9df5231SPoul-Henning Kamp * title to a string of its own choice. 619b9df5231SPoul-Henning Kamp */ 620b9df5231SPoul-Henning Kamp static int 621b9df5231SPoul-Henning Kamp sysctl_kern_proc_args SYSCTL_HANDLER_ARGS 622b9df5231SPoul-Henning Kamp { 623b9df5231SPoul-Henning Kamp int *name = (int*) arg1; 624b9df5231SPoul-Henning Kamp u_int namelen = arg2; 625b9df5231SPoul-Henning Kamp struct proc *p; 626b9df5231SPoul-Henning Kamp struct pargs *pa; 627b9df5231SPoul-Henning Kamp int error = 0; 628b9df5231SPoul-Henning Kamp 629b9df5231SPoul-Henning Kamp if (namelen != 1) 630b9df5231SPoul-Henning Kamp return (EINVAL); 631b9df5231SPoul-Henning Kamp 632b9df5231SPoul-Henning Kamp p = pfind((pid_t)name[0]); 633b9df5231SPoul-Henning Kamp if (!p) 634b9df5231SPoul-Henning Kamp return (0); 635b9df5231SPoul-Henning Kamp 636a8704f89SPoul-Henning Kamp if ((!ps_argsopen) && p_trespass(curproc, p)) 637b9df5231SPoul-Henning Kamp return (0); 638b9df5231SPoul-Henning Kamp 639b9df5231SPoul-Henning Kamp if (req->newptr && curproc != p) 640b9df5231SPoul-Henning Kamp return (EPERM); 641b9df5231SPoul-Henning Kamp 642b9df5231SPoul-Henning Kamp if (req->oldptr && p->p_args != NULL) 643b9df5231SPoul-Henning Kamp error = SYSCTL_OUT(req, p->p_args->ar_args, p->p_args->ar_length); 644b9df5231SPoul-Henning Kamp if (req->newptr == NULL) 645b9df5231SPoul-Henning Kamp return (error); 646b9df5231SPoul-Henning Kamp 647b9df5231SPoul-Henning Kamp if (p->p_args && --p->p_args->ar_ref == 0) 648b9df5231SPoul-Henning Kamp FREE(p->p_args, M_PARGS); 649b9df5231SPoul-Henning Kamp p->p_args = NULL; 650b9df5231SPoul-Henning Kamp 651b9df5231SPoul-Henning Kamp if (req->newlen + sizeof(struct pargs) > ps_arg_cache_limit) 652b9df5231SPoul-Henning Kamp return (error); 653b9df5231SPoul-Henning Kamp 654b9df5231SPoul-Henning Kamp MALLOC(pa, struct pargs *, sizeof(struct pargs) + req->newlen, 655b9df5231SPoul-Henning Kamp M_PARGS, M_WAITOK); 656b9df5231SPoul-Henning Kamp pa->ar_ref = 1; 657b9df5231SPoul-Henning Kamp pa->ar_length = req->newlen; 658b9df5231SPoul-Henning Kamp error = SYSCTL_IN(req, pa->ar_args, req->newlen); 659b9df5231SPoul-Henning Kamp if (!error) 660b9df5231SPoul-Henning Kamp p->p_args = pa; 661b9df5231SPoul-Henning Kamp else 662b9df5231SPoul-Henning Kamp FREE(pa, M_PARGS); 663b9df5231SPoul-Henning Kamp return (error); 664b9df5231SPoul-Henning Kamp } 6653ce93e4eSPoul-Henning Kamp 6663ce93e4eSPoul-Henning Kamp SYSCTL_NODE(_kern, KERN_PROC, proc, CTLFLAG_RD, 0, "Process table"); 6673ce93e4eSPoul-Henning Kamp 6683ce93e4eSPoul-Henning Kamp SYSCTL_PROC(_kern_proc, KERN_PROC_ALL, all, CTLFLAG_RD|CTLTYPE_STRUCT, 6693d177f46SBill Fumerola 0, 0, sysctl_kern_proc, "S,proc", "Return entire process table"); 6703ce93e4eSPoul-Henning Kamp 6713ce93e4eSPoul-Henning Kamp SYSCTL_NODE(_kern_proc, KERN_PROC_PGRP, pgrp, CTLFLAG_RD, 6723ce93e4eSPoul-Henning Kamp sysctl_kern_proc, "Process table"); 6733ce93e4eSPoul-Henning Kamp 6743ce93e4eSPoul-Henning Kamp SYSCTL_NODE(_kern_proc, KERN_PROC_TTY, tty, CTLFLAG_RD, 6753ce93e4eSPoul-Henning Kamp sysctl_kern_proc, "Process table"); 6763ce93e4eSPoul-Henning Kamp 6773ce93e4eSPoul-Henning Kamp SYSCTL_NODE(_kern_proc, KERN_PROC_UID, uid, CTLFLAG_RD, 6783ce93e4eSPoul-Henning Kamp sysctl_kern_proc, "Process table"); 6793ce93e4eSPoul-Henning Kamp 6803ce93e4eSPoul-Henning Kamp SYSCTL_NODE(_kern_proc, KERN_PROC_RUID, ruid, CTLFLAG_RD, 6813ce93e4eSPoul-Henning Kamp sysctl_kern_proc, "Process table"); 6823ce93e4eSPoul-Henning Kamp 6833ce93e4eSPoul-Henning Kamp SYSCTL_NODE(_kern_proc, KERN_PROC_PID, pid, CTLFLAG_RD, 684972f9b20SPoul-Henning Kamp sysctl_kern_proc, "Process table"); 685b9df5231SPoul-Henning Kamp 6869b6d9dbaSPoul-Henning Kamp SYSCTL_NODE(_kern_proc, KERN_PROC_ARGS, args, CTLFLAG_RW | CTLFLAG_ANYBODY, 6879b6d9dbaSPoul-Henning Kamp sysctl_kern_proc_args, "Process argument list"); 688