Deleted Added
full compact
kern_exit.c (157632) kern_exit.c (159054)
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 157632 2006-04-10 14:07:28Z csjp $");
38__FBSDID("$FreeBSD: head/sys/kern/kern_exit.c 159054 2006-05-29 21:28:56Z tegge $");
39
40#include "opt_compat.h"
41#include "opt_ktrace.h"
42#include "opt_mac.h"
43
44#include <sys/param.h>
45#include <sys/systm.h>
46#include <sys/sysproto.h>

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

108 * status and rusage for wait(). Check for child processes and orphan them.
109 */
110void
111exit1(struct thread *td, int rv)
112{
113 struct proc *p, *nq, *q;
114 struct tty *tp;
115 struct vnode *ttyvp;
39
40#include "opt_compat.h"
41#include "opt_ktrace.h"
42#include "opt_mac.h"
43
44#include <sys/param.h>
45#include <sys/systm.h>
46#include <sys/sysproto.h>

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

108 * status and rusage for wait(). Check for child processes and orphan them.
109 */
110void
111exit1(struct thread *td, int rv)
112{
113 struct proc *p, *nq, *q;
114 struct tty *tp;
115 struct vnode *ttyvp;
116 struct vmspace *vm;
117 struct vnode *vtmp;
118#ifdef KTRACE
119 struct vnode *tracevp;
120 struct ucred *tracecred;
121#endif
122 struct plimit *plim;
116 struct vnode *vtmp;
117#ifdef KTRACE
118 struct vnode *tracevp;
119 struct ucred *tracecred;
120#endif
121 struct plimit *plim;
123 int locked, refcnt;
122 int locked;
124
125 /*
126 * Drop Giant if caller has it. Eventually we should warn about
127 * being called with Giant held.
128 */
129 while (mtx_owned(&Giant))
130 mtx_unlock(&Giant);
131

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

295 q = p->p_leader;
296 while (q->p_peers != p)
297 q = q->p_peers;
298 q->p_peers = p->p_peers;
299 wakeup(p->p_leader);
300 }
301 mtx_unlock(&ppeers_lock);
302
123
124 /*
125 * Drop Giant if caller has it. Eventually we should warn about
126 * being called with Giant held.
127 */
128 while (mtx_owned(&Giant))
129 mtx_unlock(&Giant);
130

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

294 q = p->p_leader;
295 while (q->p_peers != p)
296 q = q->p_peers;
297 q->p_peers = p->p_peers;
298 wakeup(p->p_leader);
299 }
300 mtx_unlock(&ppeers_lock);
301
303 /* The next two chunks should probably be moved to vmspace_exit. */
304 vm = p->p_vmspace;
305 /*
306 * Release user portion of address space.
307 * This releases references to vnodes,
308 * which could cause I/O if the file has been unlinked.
309 * Need to do this early enough that we can still sleep.
310 * Can't free the entire vmspace as the kernel stack
311 * may be mapped within that space also.
312 *
313 * Processes sharing the same vmspace may exit in one order, and
314 * get cleaned up by vmspace_exit() in a different order. The
315 * last exiting process to reach this point releases as much of
316 * the environment as it can, and the last process cleaned up
317 * by vmspace_exit() (which decrements exitingcnt) cleans up the
318 * remainder.
319 */
320 atomic_add_int(&vm->vm_exitingcnt, 1);
321 do
322 refcnt = vm->vm_refcnt;
323 while (!atomic_cmpset_int(&vm->vm_refcnt, refcnt, refcnt - 1));
324 if (refcnt == 1) {
325 shmexit(vm);
326 pmap_remove_pages(vmspace_pmap(vm));
327 (void) vm_map_remove(&vm->vm_map, vm_map_min(&vm->vm_map),
328 vm_map_max(&vm->vm_map));
329 }
302 vmspace_exit(td);
330
331 sx_xlock(&proctree_lock);
332 if (SESS_LEADER(p)) {
333 struct session *sp;
334
335 sp = p->p_session;
336 if (sp->s_ttyvp) {
337 locked = VFS_LOCK_GIANT(sp->s_ttyvp->v_mount);

--- 593 unchanged lines hidden ---
303
304 sx_xlock(&proctree_lock);
305 if (SESS_LEADER(p)) {
306 struct session *sp;
307
308 sp = p->p_session;
309 if (sp->s_ttyvp) {
310 locked = VFS_LOCK_GIANT(sp->s_ttyvp->v_mount);

--- 593 unchanged lines hidden ---