Deleted Added
full compact
kern_exit.c (223088) kern_exit.c (223825)
1/*-
2 * Copyright (c) 1982, 1986, 1989, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

--- 21 unchanged lines hidden (view full) ---

30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * @(#)kern_exit.c 8.7 (Berkeley) 2/12/94
35 */
36
37#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1982, 1986, 1989, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

--- 21 unchanged lines hidden (view full) ---

30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * @(#)kern_exit.c 8.7 (Berkeley) 2/12/94
35 */
36
37#include <sys/cdefs.h>
38__FBSDID("$FreeBSD: head/sys/kern/kern_exit.c 223088 2011-06-14 17:09:30Z obrien $");
38__FBSDID("$FreeBSD: head/sys/kern/kern_exit.c 223825 2011-07-06 20:06:44Z trasz $");
39
40#include "opt_compat.h"
41#include "opt_kdtrace.h"
42#include "opt_ktrace.h"
43
44#include <sys/param.h>
45#include <sys/systm.h>
46#include <sys/sysproto.h>

--- 692 unchanged lines hidden (view full) ---

739 * Decrement the count of procs running with this uid.
740 */
741 (void)chgproccnt(p->p_ucred->cr_ruidinfo, -1, 0);
742
743 /*
744 * Destroy resource accounting information associated with the process.
745 */
746 racct_proc_exit(p);
39
40#include "opt_compat.h"
41#include "opt_kdtrace.h"
42#include "opt_ktrace.h"
43
44#include <sys/param.h>
45#include <sys/systm.h>
46#include <sys/sysproto.h>

--- 692 unchanged lines hidden (view full) ---

739 * Decrement the count of procs running with this uid.
740 */
741 (void)chgproccnt(p->p_ucred->cr_ruidinfo, -1, 0);
742
743 /*
744 * Destroy resource accounting information associated with the process.
745 */
746 racct_proc_exit(p);
747#ifdef RACCT
747 PROC_LOCK(p->p_pptr);
748 racct_sub(p->p_pptr, RACCT_NPROC, 1);
749 PROC_UNLOCK(p->p_pptr);
748 PROC_LOCK(p->p_pptr);
749 racct_sub(p->p_pptr, RACCT_NPROC, 1);
750 PROC_UNLOCK(p->p_pptr);
751#endif
750
751 /*
752 * Free credentials, arguments, and sigacts.
753 */
754 crfree(p->p_ucred);
755 p->p_ucred = NULL;
756 pargs_drop(p->p_args);
757 p->p_args = NULL;

--- 142 unchanged lines hidden (view full) ---

900
901/*
902 * Make process 'parent' the new parent of process 'child'.
903 * Must be called with an exclusive hold of proctree lock.
904 */
905void
906proc_reparent(struct proc *child, struct proc *parent)
907{
752
753 /*
754 * Free credentials, arguments, and sigacts.
755 */
756 crfree(p->p_ucred);
757 p->p_ucred = NULL;
758 pargs_drop(p->p_args);
759 p->p_args = NULL;

--- 142 unchanged lines hidden (view full) ---

902
903/*
904 * Make process 'parent' the new parent of process 'child'.
905 * Must be called with an exclusive hold of proctree lock.
906 */
907void
908proc_reparent(struct proc *child, struct proc *parent)
909{
910#ifdef RACCT
908 int locked;
911 int locked;
912#endif
909
910 sx_assert(&proctree_lock, SX_XLOCKED);
911 PROC_LOCK_ASSERT(child, MA_OWNED);
912 if (child->p_pptr == parent)
913 return;
914
913
914 sx_assert(&proctree_lock, SX_XLOCKED);
915 PROC_LOCK_ASSERT(child, MA_OWNED);
916 if (child->p_pptr == parent)
917 return;
918
919#ifdef RACCT
915 locked = PROC_LOCKED(parent);
916 if (!locked)
917 PROC_LOCK(parent);
918 racct_add_force(parent, RACCT_NPROC, 1);
919 if (!locked)
920 PROC_UNLOCK(parent);
920 locked = PROC_LOCKED(parent);
921 if (!locked)
922 PROC_LOCK(parent);
923 racct_add_force(parent, RACCT_NPROC, 1);
924 if (!locked)
925 PROC_UNLOCK(parent);
926#endif
921 PROC_LOCK(child->p_pptr);
922 racct_sub(child->p_pptr, RACCT_NPROC, 1);
923 sigqueue_take(child->p_ksi);
924 PROC_UNLOCK(child->p_pptr);
925 LIST_REMOVE(child, p_sibling);
926 LIST_INSERT_HEAD(&parent->p_children, child, p_sibling);
927 child->p_pptr = parent;
928}
927 PROC_LOCK(child->p_pptr);
928 racct_sub(child->p_pptr, RACCT_NPROC, 1);
929 sigqueue_take(child->p_ksi);
930 PROC_UNLOCK(child->p_pptr);
931 LIST_REMOVE(child, p_sibling);
932 LIST_INSERT_HEAD(&parent->p_children, child, p_sibling);
933 child->p_pptr = parent;
934}