Deleted Added
full compact
40c40
< * $FreeBSD: head/sys/kern/kern_prot.c 90756 2002-02-17 07:30:34Z dillon $
---
> * $FreeBSD: head/sys/kern/kern_prot.c 91140 2002-02-23 11:12:57Z tanimura $
53a54
> #include <sys/malloc.h>
55d55
< #include <sys/proc.h>
56a57
> #include <sys/proc.h>
59d59
< #include <sys/malloc.h>
139a140
> int s;
141c142,143
< mtx_lock(&Giant);
---
> s = mtx_lock_giant(kern_giant_proc);
> PROC_LOCK(p);
143c145,146
< mtx_unlock(&Giant);
---
> PROC_UNLOCK(p);
> mtx_unlock_giant(s);
167c170,171
< if (uap->pid == 0)
---
> if (uap->pid == 0) {
> PROC_LOCK(p);
169c173,174
< else if ((pt = pfind(uap->pid)) == NULL)
---
> PROC_UNLOCK(p);
> } else if ((pt = pfind(uap->pid)) == NULL)
199a205
> int s;
201c207
< mtx_lock(&Giant);
---
> s = mtx_lock_giant(kern_giant_proc);
203c209,210
< if (uap->pid == 0)
---
> if (uap->pid == 0) {
> PROC_LOCK(p);
205c212,213
< else if ((pt = pfind(uap->pid)) == NULL)
---
> PROC_UNLOCK(p);
> } else if ((pt = pfind(uap->pid)) == NULL)
213c221
< mtx_unlock(&Giant);
---
> mtx_unlock_giant(s);
367a376
> struct pgrp *pgrp;
369a379,380
> struct pgrp *newpgrp;
> struct session *newsess;
370a382,384
> error = 0;
> pgrp = NULL;
>
372c386,394
< if (p->p_pgid == p->p_pid || pgfind(p->p_pid))
---
>
> MALLOC(newpgrp, struct pgrp *, sizeof(struct pgrp), M_PGRP, M_WAITOK | M_ZERO);
> MALLOC(newsess, struct session *, sizeof(struct session), M_SESSION, M_WAITOK | M_ZERO);
>
> PGRPSESS_XLOCK();
>
> if (p->p_pgid == p->p_pid || (pgrp = pgfind(p->p_pid)) != NULL) {
> if (pgrp != NULL)
> PGRP_UNLOCK(pgrp);
374,375c396,398
< else {
< (void)enterpgrp(p, p->p_pid, 1);
---
> goto fail;
> } else {
> (void)enterpgrp(p, p->p_pid, newpgrp, newsess);
378a402
> PGRPSESS_XUNLOCK();
380c404,413
< return (error);
---
> return (0);
>
> fail:
> PGRPSESS_XUNLOCK();
>
> FREE(newpgrp, M_PGRP);
> FREE(newsess, M_SESSION);
>
> mtx_unlock(&Giant);
> return (0);
414a448
> struct pgrp *newpgrp;
417a452,454
>
> error = 0;
>
419c456,460
< sx_slock(&proctree_lock);
---
>
> MALLOC(newpgrp, struct pgrp *, sizeof(struct pgrp), M_PGRP, M_WAITOK | M_ZERO);
>
> PGRPSESS_XLOCK();
>
421c462,463
< if ((targp = pfind(uap->pid)) == NULL || !inferior(targp)) {
---
> sx_slock(&proctree_lock);
> if ((targp = pfind(uap->pid)) == NULL) {
423a466
> sx_sunlock(&proctree_lock);
425c468
< goto done2;
---
> goto fail;
426a470,475
> if (!inferior(targp)) {
> PROC_UNLOCK(targp);
> sx_sunlock(&proctree_lock);
> goto fail;
> }
> sx_sunlock(&proctree_lock);
429c478
< goto done2;
---
> goto fail;
435c484
< goto done2;
---
> goto fail;
440c489
< goto done2;
---
> goto fail;
442c491,492
< } else {
---
> PROC_UNLOCK(targp);
> } else
444,445d493
< PROC_LOCK(curp); /* XXX: not needed */
< }
447d494
< PROC_UNLOCK(targp);
449c496
< goto done2;
---
> goto fail;
453,454c500,507
< else if (uap->pgid != targp->p_pid) {
< if ((pgrp = pgfind(uap->pgid)) == 0 ||
---
> if (uap->pgid == targp->p_pid) {
> if (targp->p_pgid == uap->pgid)
> goto done;
> error = enterpgrp(targp, uap->pgid, newpgrp, NULL);
> if (error == 0)
> newpgrp = NULL;
> } else {
> if ((pgrp = pgfind(uap->pgid)) == NULL ||
456c509,510
< PROC_UNLOCK(targp);
---
> if (pgrp != NULL)
> PGRP_UNLOCK(pgrp);
458c512
< goto done2;
---
> goto fail;
459a514,519
> if (pgrp == targp->p_pgrp) {
> PGRP_UNLOCK(pgrp);
> goto done;
> }
> PGRP_UNLOCK(pgrp);
> error = enterthispgrp(targp, pgrp);
461,465c521,524
< /* XXX: We should probably hold the lock across enterpgrp. */
< PROC_UNLOCK(targp);
< error = enterpgrp(targp, uap->pgid, 0);
< done2:
< sx_sunlock(&proctree_lock);
---
> done:
> PGRPSESS_XUNLOCK();
> if (newpgrp != NULL)
> FREE(newpgrp, M_PGRP);
466a526,534
> return (0);
>
> fail:
> PGRPSESS_XUNLOCK();
>
> KASSERT(newpgrp != NULL, ("setpgid failed and newpgrp is null."));
> FREE(newpgrp, M_PGRP);
>
> mtx_unlock(&Giant);
1136a1205
> PROC_LOCK(p);
1137a1207
> PROC_UNLOCK(p);
1155a1226
> PROC_LOCK(td->td_proc);
1156a1228
> PROC_UNLOCK(td->td_proc);
1158a1231
> PROC_LOCK(td->td_proc);
1159a1233
> PROC_UNLOCK(td->td_proc);
1727a1802
> char login[MAXLOGNAME];
1733,1734c1808,1813
< error = copyout((caddr_t) p->p_pgrp->pg_session->s_login,
< (caddr_t) uap->namebuf, uap->namelen);
---
> PROC_LOCK(p);
> SESS_LOCK(p->p_session);
> bcopy(p->p_session->s_login, login, uap->namelen);
> SESS_UNLOCK(p->p_session);
> PROC_UNLOCK(p);
> error = copyout((caddr_t) login, (caddr_t) uap->namebuf, uap->namelen);
1767,1768c1846,1850
< else if (!error)
< (void)memcpy(p->p_pgrp->pg_session->s_login, logintmp,
---
> else if (!error) {
> PGRPSESS_XLOCK();
> PROC_LOCK(p);
> SESS_LOCK(p->p_session);
> (void) memcpy(p->p_session->s_login, logintmp,
1769a1852,1855
> SESS_UNLOCK(p->p_session);
> PROC_UNLOCK(p);
> PGRPSESS_XUNLOCK();
> }