kern_fork.c (91090) | kern_fork.c (91140) |
---|---|
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. --- 22 unchanged lines hidden (view full) --- 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)kern_fork.c 8.6 (Berkeley) 4/8/94 | 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. --- 22 unchanged lines hidden (view full) --- 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)kern_fork.c 8.6 (Berkeley) 4/8/94 |
39 * $FreeBSD: head/sys/kern/kern_fork.c 91090 2002-02-22 23:58:22Z julian $ | 39 * $FreeBSD: head/sys/kern/kern_fork.c 91140 2002-02-23 11:12:57Z tanimura $ |
40 */ 41 42#include "opt_ktrace.h" 43 44#include <sys/param.h> 45#include <sys/systm.h> 46#include <sys/sysproto.h> 47#include <sys/filedesc.h> --- 329 unchanged lines hidden (view full) --- 377 /* 378 * Scan the active and zombie procs to check whether this pid 379 * is in use. Remember the lowest pid that's greater 380 * than trypid, so we can avoid checking for a while. 381 */ 382 p2 = LIST_FIRST(&allproc); 383again: 384 for (; p2 != NULL; p2 = LIST_NEXT(p2, p_list)) { | 40 */ 41 42#include "opt_ktrace.h" 43 44#include <sys/param.h> 45#include <sys/systm.h> 46#include <sys/sysproto.h> 47#include <sys/filedesc.h> --- 329 unchanged lines hidden (view full) --- 377 /* 378 * Scan the active and zombie procs to check whether this pid 379 * is in use. Remember the lowest pid that's greater 380 * than trypid, so we can avoid checking for a while. 381 */ 382 p2 = LIST_FIRST(&allproc); 383again: 384 for (; p2 != NULL; p2 = LIST_NEXT(p2, p_list)) { |
385 PROC_LOCK(p2); |
|
385 while (p2->p_pid == trypid || 386 p2->p_pgrp->pg_id == trypid || 387 p2->p_session->s_sid == trypid) { 388 trypid++; | 386 while (p2->p_pid == trypid || 387 p2->p_pgrp->pg_id == trypid || 388 p2->p_session->s_sid == trypid) { 389 trypid++; |
389 if (trypid >= pidchecked) | 390 if (trypid >= pidchecked) { 391 PROC_UNLOCK(p2); |
390 goto retry; | 392 goto retry; |
393 } |
|
391 } 392 if (p2->p_pid > trypid && pidchecked > p2->p_pid) 393 pidchecked = p2->p_pid; 394 if (p2->p_pgrp->pg_id > trypid && 395 pidchecked > p2->p_pgrp->pg_id) 396 pidchecked = p2->p_pgrp->pg_id; 397 if (p2->p_session->s_sid > trypid && 398 pidchecked > p2->p_session->s_sid) 399 pidchecked = p2->p_session->s_sid; | 394 } 395 if (p2->p_pid > trypid && pidchecked > p2->p_pid) 396 pidchecked = p2->p_pid; 397 if (p2->p_pgrp->pg_id > trypid && 398 pidchecked > p2->p_pgrp->pg_id) 399 pidchecked = p2->p_pgrp->pg_id; 400 if (p2->p_session->s_sid > trypid && 401 pidchecked > p2->p_session->s_sid) 402 pidchecked = p2->p_session->s_sid; |
403 PROC_UNLOCK(p2); |
|
400 } 401 if (!doingzomb) { 402 doingzomb = 1; 403 p2 = LIST_FIRST(&zombproc); 404 goto again; 405 } 406 } 407 --- 146 unchanged lines hidden (view full) --- 554 p2->p_limit->p_refcnt++; 555 } 556 557 /* 558 * Preserve some more flags in subprocess. PS_PROFIL has already 559 * been preserved. 560 */ 561 p2->p_flag |= p1->p_flag & (P_SUGID | P_ALTSTACK); | 404 } 405 if (!doingzomb) { 406 doingzomb = 1; 407 p2 = LIST_FIRST(&zombproc); 408 goto again; 409 } 410 } 411 --- 146 unchanged lines hidden (view full) --- 558 p2->p_limit->p_refcnt++; 559 } 560 561 /* 562 * Preserve some more flags in subprocess. PS_PROFIL has already 563 * been preserved. 564 */ 565 p2->p_flag |= p1->p_flag & (P_SUGID | P_ALTSTACK); |
566 SESS_LOCK(p1->p_session); |
|
562 if (p1->p_session->s_ttyvp != NULL && p1->p_flag & P_CONTROLT) 563 p2->p_flag |= P_CONTROLT; | 567 if (p1->p_session->s_ttyvp != NULL && p1->p_flag & P_CONTROLT) 568 p2->p_flag |= P_CONTROLT; |
569 SESS_UNLOCK(p1->p_session); |
|
564 if (flags & RFPPWAIT) 565 p2->p_flag |= P_PPWAIT; 566 567 LIST_INSERT_AFTER(p1, p2, p_pglist); 568 PROC_UNLOCK(p1); 569 PROC_UNLOCK(p2); 570 571 /* --- 265 unchanged lines hidden --- | 570 if (flags & RFPPWAIT) 571 p2->p_flag |= P_PPWAIT; 572 573 LIST_INSERT_AFTER(p1, p2, p_pglist); 574 PROC_UNLOCK(p1); 575 PROC_UNLOCK(p2); 576 577 /* --- 265 unchanged lines hidden --- |