kern_proc.c (1542) | kern_proc.c (1549) |
---|---|
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 --- 35 unchanged lines hidden (view full) --- 44#include <sys/file.h> 45#include <ufs/ufs/quota.h> 46#include <sys/uio.h> 47#include <sys/malloc.h> 48#include <sys/mbuf.h> 49#include <sys/ioctl.h> 50#include <sys/tty.h> 51 | 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 --- 35 unchanged lines hidden (view full) --- 44#include <sys/file.h> 45#include <ufs/ufs/quota.h> 46#include <sys/uio.h> 47#include <sys/malloc.h> 48#include <sys/mbuf.h> 49#include <sys/ioctl.h> 50#include <sys/tty.h> 51 |
52void pgdelete __P((struct pgrp *)); 53void fixjobc __P((struct proc *, struct pgrp *, int)); 54 |
|
52/* 53 * Structure associated with user cacheing. 54 */ 55struct uidinfo { 56 struct uidinfo *ui_next; 57 struct uidinfo **ui_prev; 58 uid_t ui_uid; 59 long ui_proccnt; 60} **uihashtbl; 61u_long uihash; /* size of hash table - 1 */ 62#define UIHASH(uid) ((uid) & uihash) 63 64/* 65 * Allocate a hash table. 66 */ | 55/* 56 * Structure associated with user cacheing. 57 */ 58struct uidinfo { 59 struct uidinfo *ui_next; 60 struct uidinfo **ui_prev; 61 uid_t ui_uid; 62 long ui_proccnt; 63} **uihashtbl; 64u_long uihash; /* size of hash table - 1 */ 65#define UIHASH(uid) ((uid) & uihash) 66 67/* 68 * Allocate a hash table. 69 */ |
70void |
|
67usrinfoinit() 68{ 69 70 uihashtbl = hashinit(maxproc / 16, M_PROC, &uihash); 71} 72 73/* 74 * Change the count associated with number of processes --- 36 unchanged lines hidden (view full) --- 111 uip->ui_uid = uid; 112 uip->ui_proccnt = diff; 113 return (diff); 114} 115 116/* 117 * Is p an inferior of the current process? 118 */ | 71usrinfoinit() 72{ 73 74 uihashtbl = hashinit(maxproc / 16, M_PROC, &uihash); 75} 76 77/* 78 * Change the count associated with number of processes --- 36 unchanged lines hidden (view full) --- 115 uip->ui_uid = uid; 116 uip->ui_proccnt = diff; 117 return (diff); 118} 119 120/* 121 * Is p an inferior of the current process? 122 */ |
123int |
|
119inferior(p) 120 register struct proc *p; 121{ 122 123 for (; p != curproc; p = p->p_pptr) 124 if (p->p_pid == 0) 125 return (0); 126 return (1); --- 28 unchanged lines hidden (view full) --- 155 if (pgrp->pg_id == pgid) 156 return (pgrp); 157 return (NULL); 158} 159 160/* 161 * Move p to a new or existing process group (and session) 162 */ | 124inferior(p) 125 register struct proc *p; 126{ 127 128 for (; p != curproc; p = p->p_pptr) 129 if (p->p_pid == 0) 130 return (0); 131 return (1); --- 28 unchanged lines hidden (view full) --- 160 if (pgrp->pg_id == pgid) 161 return (pgrp); 162 return (NULL); 163} 164 165/* 166 * Move p to a new or existing process group (and session) 167 */ |
168int |
|
163enterpgrp(p, pgid, mksess) 164 register struct proc *p; 165 pid_t pgid; 166 int mksess; 167{ 168 register struct pgrp *pgrp = pgfind(pgid); 169 register struct proc **pp; 170 int n; --- 83 unchanged lines hidden (view full) --- 254 p->p_pgrpnxt = pgrp->pg_mem; 255 pgrp->pg_mem = p; 256 return (0); 257} 258 259/* 260 * remove process from process group 261 */ | 169enterpgrp(p, pgid, mksess) 170 register struct proc *p; 171 pid_t pgid; 172 int mksess; 173{ 174 register struct pgrp *pgrp = pgfind(pgid); 175 register struct proc **pp; 176 int n; --- 83 unchanged lines hidden (view full) --- 260 p->p_pgrpnxt = pgrp->pg_mem; 261 pgrp->pg_mem = p; 262 return (0); 263} 264 265/* 266 * remove process from process group 267 */ |
268int |
|
262leavepgrp(p) 263 register struct proc *p; 264{ 265 register struct proc **pp = &p->p_pgrp->pg_mem; 266 267 for (; *pp; pp = &(*pp)->p_pgrpnxt) { 268 if (*pp == p) { 269 *pp = p->p_pgrpnxt; --- 8 unchanged lines hidden (view full) --- 278 pgdelete(p->p_pgrp); 279 p->p_pgrp = 0; 280 return (0); 281} 282 283/* 284 * delete a process group 285 */ | 269leavepgrp(p) 270 register struct proc *p; 271{ 272 register struct proc **pp = &p->p_pgrp->pg_mem; 273 274 for (; *pp; pp = &(*pp)->p_pgrpnxt) { 275 if (*pp == p) { 276 *pp = p->p_pgrpnxt; --- 8 unchanged lines hidden (view full) --- 285 pgdelete(p->p_pgrp); 286 p->p_pgrp = 0; 287 return (0); 288} 289 290/* 291 * delete a process group 292 */ |
293void |
|
286pgdelete(pgrp) 287 register struct pgrp *pgrp; 288{ 289 register struct pgrp **pgp = &pgrphash[PIDHASH(pgrp->pg_id)]; 290 291 if (pgrp->pg_session->s_ttyp != NULL && 292 pgrp->pg_session->s_ttyp->t_pgrp == pgrp) 293 pgrp->pg_session->s_ttyp->t_pgrp = NULL; --- 19 unchanged lines hidden (view full) --- 313 * We count the number of processes in each process group that "qualify" 314 * the group for terminal job control (those with a parent in a different 315 * process group of the same session). If that count reaches zero, the 316 * process group becomes orphaned. Check both the specified process' 317 * process group and that of its children. 318 * entering == 0 => p is leaving specified group. 319 * entering == 1 => p is entering specified group. 320 */ | 294pgdelete(pgrp) 295 register struct pgrp *pgrp; 296{ 297 register struct pgrp **pgp = &pgrphash[PIDHASH(pgrp->pg_id)]; 298 299 if (pgrp->pg_session->s_ttyp != NULL && 300 pgrp->pg_session->s_ttyp->t_pgrp == pgrp) 301 pgrp->pg_session->s_ttyp->t_pgrp = NULL; --- 19 unchanged lines hidden (view full) --- 321 * We count the number of processes in each process group that "qualify" 322 * the group for terminal job control (those with a parent in a different 323 * process group of the same session). If that count reaches zero, the 324 * process group becomes orphaned. Check both the specified process' 325 * process group and that of its children. 326 * entering == 0 => p is leaving specified group. 327 * entering == 1 => p is entering specified group. 328 */ |
329void |
|
321fixjobc(p, pgrp, entering) 322 register struct proc *p; 323 register struct pgrp *pgrp; 324 int entering; 325{ 326 register struct pgrp *hispgrp; 327 register struct session *mysession = pgrp->pg_session; 328 --- 73 unchanged lines hidden --- | 330fixjobc(p, pgrp, entering) 331 register struct proc *p; 332 register struct pgrp *pgrp; 333 int entering; 334{ 335 register struct pgrp *hispgrp; 336 register struct session *mysession = pgrp->pg_session; 337 --- 73 unchanged lines hidden --- |